Improve TypeScript keyword syntax highlighting (#47435)
Andrew Currier
and
Gaauwe Rombouts
created 2 weeks ago
Improve syntax highlighting of keywords by creating groups for
declarations and import/export.
### Release Notes:
- Highlight declarations with `keyword.declaration`:
- const
- let
- var
- function
- class
- enum
- interface
- type
- Highlight imports and exports with `keyword.import`:
- export
- from
- import
---------
Co-authored-by: Gaauwe Rombouts <mail@grombouts.nl>
Change summary
crates/languages/src/javascript/highlights.scm | 22 +++++++----
crates/languages/src/tsx/highlights.scm | 37 +++++++++++++++----
crates/languages/src/typescript/highlights.scm | 28 +++++++++-----
3 files changed, 60 insertions(+), 27 deletions(-)
Detailed changes
@@ -246,20 +246,13 @@
"as"
"async"
"await"
- "class"
- "const"
"debugger"
"default"
"delete"
- "export"
"extends"
- "from"
- "function"
"get"
- "import"
"in"
"instanceof"
- "let"
"new"
"of"
"set"
@@ -267,11 +260,24 @@
"target"
"typeof"
"using"
- "var"
"void"
"with"
] @keyword
+[
+ "const"
+ "let"
+ "var"
+ "function"
+ "class"
+] @keyword.declaration
+
+[
+ "export"
+ "from"
+ "import"
+] @keyword.import
+
[
"break"
"case"
@@ -263,37 +263,58 @@
)
[
+ "abstract"
"as"
"async"
"await"
- "class"
- "const"
"debugger"
+ "declare"
"default"
"delete"
- "export"
"extends"
- "from"
- "function"
"get"
- "import"
+ "implements"
"in"
+ "infer"
"instanceof"
"is"
- "let"
+ "keyof"
+ "module"
+ "namespace"
"new"
"of"
+ "override"
+ "private"
+ "protected"
+ "public"
+ "readonly"
"satisfies"
"set"
"static"
"target"
"typeof"
"using"
- "var"
"void"
"with"
] @keyword
+[
+ "const"
+ "let"
+ "var"
+ "function"
+ "class"
+ "enum"
+ "interface"
+ "type"
+] @keyword.declaration
+
+[
+ "export"
+ "from"
+ "import"
+] @keyword.import
+
[
"break"
"case"
@@ -383,27 +383,18 @@
"as"
"async"
"await"
- "class"
- "const"
"debugger"
"declare"
"default"
"delete"
- "enum"
- "export"
"extends"
- "from"
- "function"
"get"
"implements"
- "import"
"in"
"infer"
"instanceof"
- "interface"
"is"
"keyof"
- "let"
"module"
"namespace"
"new"
@@ -417,14 +408,29 @@
"set"
"static"
"target"
- "type"
"typeof"
"using"
- "var"
"void"
"with"
] @keyword
+[
+ "const"
+ "let"
+ "var"
+ "function"
+ "class"
+ "enum"
+ "interface"
+ "type"
+] @keyword.declaration
+
+[
+ "export"
+ "from"
+ "import"
+] @keyword.import
+
[
"break"
"case"