mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-29 21:54:54 +01:00
This PR improves the vscode syntax highlighting.
- Added `comment` keys.
- Added highlighting of invalid numbers such as `0x`, `0b`, `0xa`, etc.
- Restricted highlighting of numeric type literals to common types to
avoid highlighting identifiers such as `i1`.
- Changed the highlighting of named operators (e.g., `as`).
- Added `char` and `str` to type literals.
- Added `const` to modifier keywords.
- Removed `addr` keyword.
- Refactored some rules to use `begin`/`end` to handle line breaks.
- Added highlighting to `choice` values as `enum` values.
- Updated the rules for matching `types`.
- Added highlighting to rhs of `adapt`, `alias`, `choice`, `constraint`,
`impl`, `interface`, `as`, and `impls`.
- Added highlighting to rhs of bindings.
- Added highlighting to function return types.
- Updated the rules for matching `functions`.
- Updated the rules for matching `variables`.
- Added highlighting unidentified words as `variable`.
- Added examples and before/after screenshots.
| Before | After |
| :---: | :---: |
| <img width="424" alt="before"
src="https://github.com/user-attachments/assets/e84d0ff9-237b-40c2-845b-ec550b8f7bea">
| <img width="431" alt="now"
src="https://github.com/user-attachments/assets/2c18640b-318a-4cd5-952c-bad61d3fdbca">
|
---------
Co-authored-by: Dana Jansens <danakj@orodu.net>
47 lines
895 B
Plaintext
47 lines
895 B
Plaintext
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
|
|
// Exceptions. See /LICENSE for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
|
|
// --- operators
|
|
|
|
>>= <=> <<= &= == != >= >> <= << -= -> -- %= \ = += ++ /= *= & ^ = > < - % . | + / *
|
|
and as impls in like not or partial ref template where
|
|
|
|
// --- special-keywords
|
|
|
|
break case continue else if for match return returned then while
|
|
default =>
|
|
|
|
// --- introducer-keywords
|
|
|
|
adapt alias choice class constraint fn import interface let library namespace var
|
|
base
|
|
export
|
|
impl
|
|
package
|
|
|
|
// --- modifier-keywords
|
|
|
|
abstract const extend extern final private protected virtual
|
|
base class
|
|
default
|
|
export import
|
|
impl fn
|
|
impl library
|
|
impl package
|
|
|
|
// --- misc-keywords
|
|
|
|
auto destructor forall friend observe override require
|
|
.base
|
|
|
|
// --- self-keywords
|
|
|
|
self Self
|
|
|
|
// --- underscore
|
|
|
|
;
|
|
_
|
|
_some_var
|