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; Special identifiers
 51
 52((identifier) @type
 53 (#match? @type "^[A-Z]"))
 54(type_identifier) @type
 55(predefined_type) @type.builtin
 56
 57([
 58  (identifier)
 59  (shorthand_property_identifier)
 60  (shorthand_property_identifier_pattern)
 61 ] @constant
 62 (#match? @constant "^_*[A-Z_][A-Z\\d_]*$"))
 63
 64; Literals
 65
 66(this) @variable.special
 67(super) @variable.special
 68
 69[
 70  (null)
 71  (undefined)
 72] @constant.builtin
 73
 74[
 75  (true)
 76  (false)
 77] @boolean
 78
 79(comment) @comment
 80
 81[
 82  (string)
 83  (template_string)
 84  (template_literal_type)
 85] @string
 86
 87(escape_sequence) @string.escape
 88
 89(regex) @string.regex
 90(regex_flags) @keyword.operator.regex
 91(number) @number
 92
 93; Tokens
 94
 95[
 96  ";"
 97  "?."
 98  "."
 99  ","
100  ":"
101  "?"
102] @punctuation.delimiter
103
104[
105  "-"
106  "--"
107  "-="
108  "+"
109  "++"
110  "+="
111  "*"
112  "*="
113  "**"
114  "**="
115  "/"
116  "/="
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] @operator
151
152(regex "/" @string.regex)
153
154[
155  "("
156  ")"
157  "["
158  "]"
159  "{"
160  "}"
161]  @punctuation.bracket
162
163(ternary_expression
164  [
165    "?"
166    ":"
167  ] @operator
168)
169
170[
171  "as"
172  "async"
173  "await"
174  "break"
175  "case"
176  "catch"
177  "class"
178  "const"
179  "continue"
180  "debugger"
181  "default"
182  "delete"
183  "do"
184  "else"
185  "export"
186  "extends"
187  "finally"
188  "for"
189  "from"
190  "function"
191  "get"
192  "if"
193  "import"
194  "in"
195  "instanceof"
196  "is"
197  "let"
198  "new"
199  "of"
200  "return"
201  "satisfies"
202  "set"
203  "static"
204  "switch"
205  "target"
206  "throw"
207  "try"
208  "typeof"
209  "using"
210  "var"
211  "void"
212  "while"
213  "with"
214  "yield"
215] @keyword
216
217(template_substitution
218  "${" @punctuation.special
219  "}" @punctuation.special) @embedded
220
221(template_type
222  "${" @punctuation.special
223  "}" @punctuation.special) @embedded
224
225(type_arguments
226  "<" @punctuation.bracket
227  ">" @punctuation.bracket)
228
229(decorator "@" @punctuation.special)
230
231; Keywords
232
233[ "abstract"
234  "declare"
235  "enum"
236  "export"
237  "implements"
238  "interface"
239  "keyof"
240  "module"
241  "namespace"
242  "private"
243  "protected"
244  "public"
245  "type"
246  "readonly"
247  "override"
248] @keyword
249
250; JSX elements
251(jsx_opening_element (identifier) @tag.jsx (#match? @tag.jsx "^[a-z][^.]*$"))
252(jsx_closing_element (identifier) @tag.jsx (#match? @tag.jsx "^[a-z][^.]*$"))
253(jsx_self_closing_element (identifier) @tag.jsx (#match? @tag.jsx "^[a-z][^.]*$"))
254
255(jsx_attribute (property_identifier) @attribute.jsx)
256(jsx_opening_element (["<" ">"]) @punctuation.bracket.jsx)
257(jsx_closing_element (["</" ">"]) @punctuation.bracket.jsx)
258(jsx_self_closing_element (["<" "/>"]) @punctuation.bracket.jsx)
259(jsx_attribute "=" @punctuation.delimiter.jsx)
260(jsx_text) @text.jsx