highlights.scm

  1; Variables
  2
  3(identifier) @variable
  4
  5; Properties
  6
  7(property_identifier) @property
  8(shorthand_property_identifier) @property
  9(shorthand_property_identifier_pattern) @property
 10(private_property_identifier) @property
 11
 12; Function and method calls
 13
 14(call_expression
 15  function: (identifier) @function)
 16
 17(call_expression
 18  function: (member_expression
 19    property: [(property_identifier) (private_property_identifier)] @function.method))
 20
 21; Function and method definitions
 22
 23(function_expression
 24  name: (identifier) @function)
 25(function_declaration
 26  name: (identifier) @function)
 27(method_definition
 28  name: [(property_identifier) (private_property_identifier)] @function.method)
 29(method_definition
 30    name: (property_identifier) @constructor
 31    (#eq? @constructor "constructor"))
 32
 33(pair
 34  key: [(property_identifier) (private_property_identifier)] @function.method
 35  value: [(function_expression) (arrow_function)])
 36
 37(assignment_expression
 38  left: (member_expression
 39    property: [(property_identifier) (private_property_identifier)] @function.method)
 40  right: [(function_expression) (arrow_function)])
 41
 42(variable_declarator
 43  name: (identifier) @function
 44  value: [(function_expression) (arrow_function)])
 45
 46(assignment_expression
 47  left: (identifier) @function
 48  right: [(function_expression) (arrow_function)])
 49
 50; Parameters
 51
 52(required_parameter
 53  (identifier) @variable.parameter)
 54
 55(required_parameter
 56  (_
 57    ([
 58      (identifier)
 59      (shorthand_property_identifier_pattern)
 60    ]) @variable.parameter))
 61
 62(optional_parameter
 63  (identifier) @variable.parameter)
 64
 65(optional_parameter
 66  (_
 67    ([
 68      (identifier)
 69      (shorthand_property_identifier_pattern)
 70    ]) @variable.parameter))
 71
 72(catch_clause
 73  parameter: (identifier) @variable.parameter)
 74
 75(index_signature
 76  name: (identifier) @variable.parameter)
 77
 78(arrow_function
 79  parameter: (identifier) @variable.parameter)
 80
 81(type_predicate
 82  name: (identifier) @variable.parameter)
 83
 84; Special identifiers
 85
 86(type_annotation) @type
 87(type_identifier) @type
 88(predefined_type) @type.builtin
 89
 90(type_alias_declaration
 91  (type_identifier) @type)
 92
 93(type_alias_declaration
 94  value: (_
 95    (type_identifier) @type))
 96
 97(interface_declaration
 98  (type_identifier) @type)
 99
100(class_declaration
101  (type_identifier) @type.class)
102
103(extends_clause
104  value: (identifier) @type.class)
105
106(extends_type_clause
107  type: (type_identifier) @type)
108
109(implements_clause
110  (type_identifier) @type)
111
112([
113  (identifier)
114  (shorthand_property_identifier)
115  (shorthand_property_identifier_pattern)
116 ] @constant
117 (#match? @constant "^_*[A-Z_][A-Z\\d_]*$"))
118
119; Literals
120
121(this) @variable.special
122(super) @variable.special
123
124[
125  (null)
126  (undefined)
127] @constant.builtin
128
129[
130  (true)
131  (false)
132] @boolean
133
134(comment) @comment
135
136[
137  (string)
138  (template_string)
139  (template_literal_type)
140] @string
141
142(escape_sequence) @string.escape
143
144(regex) @string.regex
145(regex_flags) @keyword.operator.regex
146(number) @number
147
148; Tokens
149
150[
151  ";"
152  "?."
153  "."
154  ","
155  ":"
156  "?"
157] @punctuation.delimiter
158
159[
160  "-"
161  "--"
162  "-="
163  "+"
164  "++"
165  "+="
166  "*"
167  "*="
168  "**"
169  "**="
170  "/"
171  "/="
172  "%"
173  "%="
174  "<"
175  "<="
176  "<<"
177  "<<="
178  "="
179  "=="
180  "==="
181  "!"
182  "!="
183  "!=="
184  "=>"
185  ">"
186  ">="
187  ">>"
188  ">>="
189  ">>>"
190  ">>>="
191  "~"
192  "^"
193  "&"
194  "|"
195  "^="
196  "&="
197  "|="
198  "&&"
199  "||"
200  "??"
201  "&&="
202  "||="
203  "??="
204  "..."
205] @operator
206
207(regex "/" @string.regex)
208
209[
210  "("
211  ")"
212  "["
213  "]"
214  "{"
215  "}"
216]  @punctuation.bracket
217
218(ternary_expression
219  [
220    "?"
221    ":"
222  ] @operator
223)
224
225[
226  "as"
227  "async"
228  "await"
229  "class"
230  "const"
231  "debugger"
232  "default"
233  "delete"
234  "export"
235  "extends"
236  "from"
237  "function"
238  "get"
239  "import"
240  "in"
241  "instanceof"
242  "is"
243  "let"
244  "new"
245  "of"
246  "satisfies"
247  "set"
248  "static"
249  "target"
250  "typeof"
251  "using"
252  "var"
253  "void"
254  "with"
255] @keyword
256
257[
258  "break"
259  "case"
260  "catch"
261  "continue"
262  "do"
263  "else"
264  "finally"
265  "for"
266  "if"
267  "return"
268  "switch"
269  "throw"
270  "try"
271  "while"
272  "yield"
273] @keyword.control
274
275(switch_default "default" @keyword.control)
276
277(template_substitution
278  "${" @punctuation.special
279  "}" @punctuation.special) @embedded
280
281(template_type
282  "${" @punctuation.special
283  "}" @punctuation.special) @embedded
284
285(type_arguments
286  "<" @punctuation.bracket
287  ">" @punctuation.bracket)
288
289(type_parameters
290  "<" @punctuation.bracket
291  ">" @punctuation.bracket)
292
293(decorator "@" @punctuation.special)
294
295(union_type
296  ("|") @punctuation.special)
297
298(intersection_type
299  ("&") @punctuation.special)
300
301(type_annotation
302  (":") @punctuation.special)
303
304(index_signature
305  (":") @punctuation.special)
306
307(type_predicate_annotation
308  (":") @punctuation.special)
309
310(public_field_definition
311  ("?") @punctuation.special)
312
313(property_signature
314  ("?") @punctuation.special)
315
316(method_signature
317  ("?") @punctuation.special)
318
319(optional_parameter
320  ([
321    "?"
322    ":"
323  ]) @punctuation.special)
324
325; Keywords
326
327[ "abstract"
328  "declare"
329  "enum"
330  "export"
331  "implements"
332  "interface"
333  "keyof"
334  "module"
335  "namespace"
336  "private"
337  "protected"
338  "public"
339  "type"
340  "readonly"
341  "override"
342] @keyword
343
344; JSX elements
345(jsx_opening_element (identifier) @tag.jsx (#match? @tag.jsx "^[a-z][^.]*$"))
346(jsx_closing_element (identifier) @tag.jsx (#match? @tag.jsx "^[a-z][^.]*$"))
347(jsx_self_closing_element (identifier) @tag.jsx (#match? @tag.jsx "^[a-z][^.]*$"))
348
349(jsx_attribute (property_identifier) @attribute.jsx)
350(jsx_opening_element (["<" ">"]) @punctuation.bracket.jsx)
351(jsx_closing_element (["</" ">"]) @punctuation.bracket.jsx)
352(jsx_self_closing_element (["<" "/>"]) @punctuation.bracket.jsx)
353(jsx_attribute "=" @punctuation.delimiter.jsx)
354(jsx_text) @text.jsx