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; Special identifiers
 82;
 83(class_declaration
 84  (type_identifier) @type.class)
 85
 86(extends_clause
 87  value: (identifier) @type.class)
 88
 89(type_identifier) @type
 90(predefined_type) @type.builtin
 91
 92([
 93  (identifier)
 94  (shorthand_property_identifier)
 95  (shorthand_property_identifier_pattern)
 96 ] @constant
 97 (#match? @constant "^_*[A-Z_][A-Z\\d_]*$"))
 98
 99; Literals
100
101(this) @variable.special
102(super) @variable.special
103
104[
105  (null)
106  (undefined)
107] @constant.builtin
108
109[
110  (true)
111  (false)
112] @boolean
113
114(comment) @comment
115
116(hash_bang_line) @comment
117
118[
119  (string)
120  (template_string)
121] @string
122
123(escape_sequence) @string.escape
124
125(regex) @string.regex
126(regex_flags) @keyword.operator.regex
127(number) @number
128
129; Tokens
130
131[
132  ";"
133  "?."
134  "."
135  ","
136  ":"
137] @punctuation.delimiter
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  "=>"
165  ">"
166  ">="
167  ">>"
168  ">>="
169  ">>>"
170  ">>>="
171  "~"
172  "^"
173  "&"
174  "|"
175  "^="
176  "&="
177  "|="
178  "&&"
179  "||"
180  "??"
181  "&&="
182  "||="
183  "??="
184  "..."
185] @operator
186
187(regex "/" @string.regex)
188
189[
190  "("
191  ")"
192  "["
193  "]"
194  "{"
195  "}"
196]  @punctuation.bracket
197
198(ternary_expression
199  [
200    "?"
201    ":"
202  ] @operator
203)
204
205[
206  "as"
207  "async"
208  "await"
209  "class"
210  "const"
211  "debugger"
212  "default"
213  "delete"
214  "export"
215  "extends"
216  "from"
217  "function"
218  "get"
219  "import"
220  "in"
221  "instanceof"
222  "let"
223  "new"
224  "of"
225  "set"
226  "static"
227  "target"
228  "typeof"
229  "using"
230  "var"
231  "void"
232  "with"
233] @keyword
234
235[
236  "break"
237  "case"
238  "catch"
239  "continue"
240  "do"
241  "else"
242  "finally"
243  "for"
244  "if"
245  "return"
246  "switch"
247  "throw"
248  "try"
249  "while"
250  "yield"
251] @keyword.control
252
253(switch_default "default" @keyword.control)
254
255(template_substitution
256  "${" @punctuation.special
257  "}" @punctuation.special) @embedded
258
259(type_arguments
260  "<" @punctuation.bracket
261  ">" @punctuation.bracket)
262
263(decorator "@" @punctuation.special)
264
265; Keywords
266
267[ "abstract"
268  "declare"
269  "enum"
270  "export"
271  "implements"
272  "interface"
273  "keyof"
274  "module"
275  "namespace"
276  "private"
277  "protected"
278  "public"
279  "type"
280  "readonly"
281  "override"
282] @keyword
283
284; JSX elements
285(jsx_opening_element (identifier) @tag.jsx (#match? @tag.jsx "^[a-z][^.]*$"))
286(jsx_closing_element (identifier) @tag.jsx (#match? @tag.jsx "^[a-z][^.]*$"))
287(jsx_self_closing_element (identifier) @tag.jsx (#match? @tag.jsx "^[a-z][^.]*$"))
288
289(jsx_attribute (property_identifier) @attribute.jsx)
290(jsx_opening_element (["<" ">"]) @punctuation.bracket.jsx)
291(jsx_closing_element (["</" ">"]) @punctuation.bracket.jsx)
292(jsx_self_closing_element (["<" "/>"]) @punctuation.bracket.jsx)
293(jsx_attribute "=" @punctuation.delimiter.jsx)
294(jsx_text) @text.jsx