highlights.scm

  1; Variables
  2
  3(identifier) @variable
  4
  5; Special identifiers
  6
  7((identifier) @type
  8 (#match? @type "^[A-Z]"))
  9(type_identifier) @type
 10(predefined_type) @type.builtin
 11
 12(import_specifier
 13  "type"
 14  name: (identifier) @type
 15  alias: (identifier) @type
 16)
 17
 18(import_statement
 19  "type"
 20  (import_clause
 21    (named_imports
 22      (import_specifier
 23        name: (identifier) @type
 24        alias: (identifier) @type
 25      )
 26    )
 27  )
 28)
 29
 30([
 31  (identifier)
 32  (shorthand_property_identifier)
 33  (shorthand_property_identifier_pattern)
 34 ] @constant
 35 (#match? @constant "^_*[A-Z_][A-Z\\d_]*$"))
 36
 37; Properties
 38
 39(property_identifier) @property
 40(shorthand_property_identifier) @property
 41(shorthand_property_identifier_pattern) @property
 42
 43; Function and method calls
 44
 45(call_expression
 46  function: (identifier) @function)
 47
 48(call_expression
 49  function: (member_expression
 50    property: (property_identifier) @function.method))
 51
 52; Function and method definitions
 53
 54(function_expression
 55  name: (identifier) @function)
 56(function_declaration
 57  name: (identifier) @function)
 58(method_definition
 59  name: (property_identifier) @function.method)
 60
 61(pair
 62  key: (property_identifier) @function.method
 63  value: [(function_expression) (arrow_function)])
 64
 65(assignment_expression
 66  left: (member_expression
 67    property: (property_identifier) @function.method)
 68  right: [(function_expression) (arrow_function)])
 69
 70(variable_declarator
 71  name: (identifier) @function
 72  value: [(function_expression) (arrow_function)])
 73
 74(assignment_expression
 75  left: (identifier) @function
 76  right: [(function_expression) (arrow_function)])
 77
 78; Literals
 79
 80(this) @keyword
 81(super) @keyword
 82
 83[
 84  (null)
 85  (undefined)
 86] @constant.builtin
 87
 88[
 89  (true)
 90  (false)
 91] @boolean
 92
 93(literal_type
 94  [
 95    (null)
 96    (undefined)
 97    (true)
 98    (false)
 99  ] @type.builtin
100)
101
102(comment) @comment
103
104[
105  (string)
106  (template_string)
107  (template_literal_type)
108] @string
109
110(escape_sequence) @string.escape
111
112(regex) @string.regex
113(regex_flags) @keyword.regex
114(number) @number
115
116; Tokens
117
118[
119  "..."
120  "-"
121  "--"
122  "-="
123  "+"
124  "++"
125  "+="
126  "*"
127  "*="
128  "**"
129  "**="
130  "/"
131  "/="
132  "%"
133  "%="
134  "<"
135  "<="
136  "<<"
137  "<<="
138  "="
139  "=="
140  "==="
141  "!"
142  "!="
143  "!=="
144  "=>"
145  ">"
146  ">="
147  ">>"
148  ">>="
149  ">>>"
150  ">>>="
151  "~"
152  "^"
153  "&"
154  "|"
155  "^="
156  "&="
157  "|="
158  "&&"
159  "||"
160  "??"
161  "&&="
162  "||="
163  "??="
164] @operator
165
166(ternary_expression
167  [
168    "?"
169    ":"
170  ] @operator
171)
172
173[
174  ";"
175  "?."
176  "."
177  ","
178  ":"
179  "?"
180] @punctuation.delimiter
181
182[
183  "("
184  ")"
185  "["
186  "]"
187  "{"
188  "}"
189]  @punctuation.bracket
190
191(template_substitution
192  "${" @punctuation.special
193  "}" @punctuation.special) @embedded
194
195(template_type
196  "${" @punctuation.special
197  "}" @punctuation.special) @embedded
198
199(type_arguments
200  "<" @punctuation.bracket
201  ">" @punctuation.bracket)
202
203(decorator "@" @punctuation.special)
204
205; Keywords
206
207[
208  "abstract"
209  "as"
210  "async"
211  "await"
212  "break"
213  "case"
214  "catch"
215  "class"
216  "const"
217  "continue"
218  "debugger"
219  "declare"
220  "default"
221  "delete"
222  "do"
223  "else"
224  "enum"
225  "export"
226  "extends"
227  "finally"
228  "for"
229  "from"
230  "function"
231  "get"
232  "if"
233  "implements"
234  "import"
235  "in"
236  "infer"
237  "instanceof"
238  "interface"
239  "is"
240  "keyof"
241  "let"
242  "namespace"
243  "new"
244  "of"
245  "override"
246  "private"
247  "protected"
248  "public"
249  "readonly"
250  "return"
251  "satisfies"
252  "set"
253  "static"
254  "switch"
255  "target"
256  "throw"
257  "try"
258  "type"
259  "typeof"
260  "using"
261  "var"
262  "void"
263  "while"
264  "with"
265  "yield"
266] @keyword