highlights.scm

  1; Variables
  2(identifier) @variable
  3
  4(call_expression
  5  function: (member_expression
  6    object: (identifier) @type
  7    (#any-of? @type
  8      "Promise" "Array" "Object" "Map" "Set" "WeakMap" "WeakSet" "Date" "Error" "TypeError"
  9      "RangeError" "SyntaxError" "ReferenceError" "EvalError" "URIError" "RegExp" "Function"
 10      "Number" "String" "Boolean" "Symbol" "BigInt" "Proxy" "ArrayBuffer" "DataView")))
 11
 12; Properties
 13(property_identifier) @property
 14
 15(shorthand_property_identifier) @property
 16
 17(shorthand_property_identifier_pattern) @property
 18
 19(private_property_identifier) @property
 20
 21; Function and method calls
 22(call_expression
 23  function: (identifier) @function)
 24
 25(call_expression
 26  function: (member_expression
 27    property: [
 28      (property_identifier)
 29      (private_property_identifier)
 30    ] @function.method))
 31
 32(new_expression
 33  constructor: (identifier) @type)
 34
 35(nested_type_identifier
 36  module: (identifier) @type)
 37
 38; Function and method definitions
 39(function_expression
 40  name: (identifier) @function)
 41
 42(function_declaration
 43  name: (identifier) @function)
 44
 45(method_definition
 46  name: [
 47    (property_identifier)
 48    (private_property_identifier)
 49  ] @function.method)
 50
 51(method_definition
 52  name: (property_identifier) @constructor
 53  (#eq? @constructor "constructor"))
 54
 55(pair
 56  key: [
 57    (property_identifier)
 58    (private_property_identifier)
 59  ] @function.method
 60  value: [
 61    (function_expression)
 62    (arrow_function)
 63  ])
 64
 65(assignment_expression
 66  left: (member_expression
 67    property: [
 68      (property_identifier)
 69      (private_property_identifier)
 70    ] @function.method)
 71  right: [
 72    (function_expression)
 73    (arrow_function)
 74  ])
 75
 76(variable_declarator
 77  name: (identifier) @function
 78  value: [
 79    (function_expression)
 80    (arrow_function)
 81  ])
 82
 83(assignment_expression
 84  left: (identifier) @function
 85  right: [
 86    (function_expression)
 87    (arrow_function)
 88  ])
 89
 90; Parameters
 91(required_parameter
 92  (identifier) @variable.parameter)
 93
 94(required_parameter
 95  (_
 96    ([
 97      (identifier)
 98      (shorthand_property_identifier_pattern)
 99    ]) @variable.parameter))
100
101(optional_parameter
102  (identifier) @variable.parameter)
103
104(optional_parameter
105  (_
106    ([
107      (identifier)
108      (shorthand_property_identifier_pattern)
109    ]) @variable.parameter))
110
111(catch_clause
112  parameter: (identifier) @variable.parameter)
113
114(index_signature
115  name: (identifier) @variable.parameter)
116
117(arrow_function
118  parameter: (identifier) @variable.parameter)
119
120(type_predicate
121  name: (identifier) @variable.parameter)
122
123; Special identifiers
124(type_annotation) @type
125
126(type_identifier) @type
127
128(predefined_type) @type.builtin
129
130(type_alias_declaration
131  (type_identifier) @type)
132
133(type_alias_declaration
134  value: (_
135    (type_identifier) @type))
136
137(interface_declaration
138  (type_identifier) @type)
139
140(class_declaration
141  (type_identifier) @type.class)
142
143(extends_clause
144  value: (identifier) @type.class)
145
146(extends_type_clause
147  type: (type_identifier) @type)
148
149(implements_clause
150  (type_identifier) @type)
151
152([
153  (identifier)
154  (shorthand_property_identifier)
155  (shorthand_property_identifier_pattern)
156] @constant
157  (#match? @constant "^_*[A-Z_][A-Z\\d_]*$"))
158
159; Literals
160(this) @variable.special
161
162(super) @variable.special
163
164[
165  (null)
166  (undefined)
167] @constant.builtin
168
169[
170  (true)
171  (false)
172] @boolean
173
174(comment) @comment
175
176[
177  (string)
178  (template_string)
179  (template_literal_type)
180] @string
181
182(escape_sequence) @string.escape
183
184(regex) @string.regex
185
186(regex_flags) @keyword.operator.regex
187
188(number) @number
189
190; Tokens
191[
192  ";"
193  "?."
194  "."
195  ","
196  ":"
197  "?"
198] @punctuation.delimiter
199
200[
201  "-"
202  "--"
203  "-="
204  "+"
205  "++"
206  "+="
207  "*"
208  "*="
209  "**"
210  "**="
211  "/"
212  "/="
213  "%"
214  "%="
215  "<"
216  "<="
217  "<<"
218  "<<="
219  "="
220  "=="
221  "==="
222  "!"
223  "!="
224  "!=="
225  "=>"
226  ">"
227  ">="
228  ">>"
229  ">>="
230  ">>>"
231  ">>>="
232  "~"
233  "^"
234  "&"
235  "|"
236  "^="
237  "&="
238  "|="
239  "&&"
240  "||"
241  "??"
242  "&&="
243  "||="
244  "??="
245  "..."
246] @operator
247
248(regex
249  "/" @string.regex)
250
251[
252  "("
253  ")"
254  "["
255  "]"
256  "{"
257  "}"
258] @punctuation.bracket
259
260(ternary_expression
261  [
262    "?"
263    ":"
264  ] @operator)
265
266; Keywords
267[
268  "abstract"
269  "as"
270  "async"
271  "debugger"
272  "declare"
273  "default"
274  "delete"
275  "extends"
276  "get"
277  "implements"
278  "in"
279  "infer"
280  "instanceof"
281  "is"
282  "keyof"
283  "module"
284  "namespace"
285  "new"
286  "of"
287  "override"
288  "private"
289  "protected"
290  "public"
291  "readonly"
292  "satisfies"
293  "set"
294  "static"
295  "target"
296  "typeof"
297  "using"
298  "void"
299  "with"
300] @keyword
301
302[
303  "const"
304  "let"
305  "var"
306  "function"
307  "class"
308  "enum"
309  "interface"
310  "type"
311] @keyword.declaration
312
313[
314  "export"
315  "from"
316  "import"
317] @keyword.import
318
319[
320  "await"
321  "break"
322  "case"
323  "catch"
324  "continue"
325  "do"
326  "else"
327  "finally"
328  "for"
329  "if"
330  "return"
331  "switch"
332  "throw"
333  "try"
334  "while"
335  "yield"
336] @keyword.control
337
338(switch_default
339  "default" @keyword.control)
340
341(template_substitution
342  "${" @punctuation.special
343  "}" @punctuation.special) @embedded
344
345(template_type
346  "${" @punctuation.special
347  "}" @punctuation.special) @embedded
348
349(type_arguments
350  "<" @punctuation.bracket
351  ">" @punctuation.bracket)
352
353(type_parameters
354  "<" @punctuation.bracket
355  ">" @punctuation.bracket)
356
357(decorator
358  "@" @punctuation.special)
359
360(union_type
361  "|" @punctuation.special)
362
363(intersection_type
364  "&" @punctuation.special)
365
366(type_annotation
367  ":" @punctuation.special)
368
369(index_signature
370  ":" @punctuation.special)
371
372(type_predicate_annotation
373  ":" @punctuation.special)
374
375(public_field_definition
376  "?" @punctuation.special)
377
378(property_signature
379  "?" @punctuation.special)
380
381(method_signature
382  "?" @punctuation.special)
383
384(optional_parameter
385  ([
386    "?"
387    ":"
388  ]) @punctuation.special)
389
390(jsx_opening_element
391  [
392    (identifier) @type @tag.component.jsx
393    (member_expression
394      object: (identifier) @type @tag.component.jsx
395      property: (property_identifier) @type @tag.component.jsx)
396    (member_expression
397      object: (member_expression
398        object: (identifier) @type @tag.component.jsx
399        property: (property_identifier) @type @tag.component.jsx)
400      property: (property_identifier) @type @tag.component.jsx)
401    (member_expression
402      object: (member_expression
403        object: (member_expression
404          object: (identifier) @type @tag.component.jsx
405          property: (property_identifier) @type @tag.component.jsx)
406        property: (property_identifier) @type @tag.component.jsx)
407      property: (property_identifier) @type @tag.component.jsx)
408  ])
409
410(jsx_closing_element
411  [
412    (identifier) @type @tag.component.jsx
413    (member_expression
414      object: (identifier) @type @tag.component.jsx
415      property: (property_identifier) @type @tag.component.jsx)
416    (member_expression
417      object: (member_expression
418        object: (identifier) @type @tag.component.jsx
419        property: (property_identifier) @type @tag.component.jsx)
420      property: (property_identifier) @type @tag.component.jsx)
421    (member_expression
422      object: (member_expression
423        object: (member_expression
424          object: (identifier) @type @tag.component.jsx
425          property: (property_identifier) @type @tag.component.jsx)
426        property: (property_identifier) @type @tag.component.jsx)
427      property: (property_identifier) @type @tag.component.jsx)
428  ])
429
430(jsx_self_closing_element
431  [
432    (identifier) @type @tag.component.jsx
433    (member_expression
434      object: (identifier) @type @tag.component.jsx
435      property: (property_identifier) @type @tag.component.jsx)
436    (member_expression
437      object: (member_expression
438        object: (identifier) @type @tag.component.jsx
439        property: (property_identifier) @type @tag.component.jsx)
440      property: (property_identifier) @type @tag.component.jsx)
441    (member_expression
442      object: (member_expression
443        object: (member_expression
444          object: (identifier) @type @tag.component.jsx
445          property: (property_identifier) @type @tag.component.jsx)
446        property: (property_identifier) @type @tag.component.jsx)
447      property: (property_identifier) @type @tag.component.jsx)
448  ])
449
450(jsx_opening_element
451  (identifier) @tag.jsx
452  (#match? @tag.jsx "^[a-z][^.]*$"))
453
454(jsx_closing_element
455  (identifier) @tag.jsx
456  (#match? @tag.jsx "^[a-z][^.]*$"))
457
458(jsx_self_closing_element
459  (identifier) @tag.jsx
460  (#match? @tag.jsx "^[a-z][^.]*$"))
461
462(jsx_attribute
463  (property_identifier) @attribute.jsx)
464
465(jsx_opening_element
466  ([
467    "<"
468    ">"
469  ]) @punctuation.bracket.jsx)
470
471(jsx_closing_element
472  ([
473    "</"
474    ">"
475  ]) @punctuation.bracket.jsx)
476
477(jsx_self_closing_element
478  ([
479    "<"
480    "/>"
481  ]) @punctuation.bracket.jsx)
482
483(jsx_attribute
484  "=" @punctuation.delimiter.jsx)
485
486(jsx_text) @text.jsx
487
488(html_character_reference) @string.special