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
11; Function and method calls
12
13(call_expression
14 function: (identifier) @function)
15
16(call_expression
17 function: (member_expression
18 property: (property_identifier) @function.method))
19
20; Function and method definitions
21
22(function_expression
23 name: (identifier) @function)
24(function_declaration
25 name: (identifier) @function)
26(method_definition
27 name: (property_identifier) @function.method)
28
29(pair
30 key: (property_identifier) @function.method
31 value: [(function_expression) (arrow_function)])
32
33(assignment_expression
34 left: (member_expression
35 property: (property_identifier) @function.method)
36 right: [(function_expression) (arrow_function)])
37
38(variable_declarator
39 name: (identifier) @function
40 value: [(function_expression) (arrow_function)])
41
42(assignment_expression
43 left: (identifier) @function
44 right: [(function_expression) (arrow_function)])
45
46; Special identifiers
47
48((identifier) @type
49 (#match? @type "^[A-Z]"))
50(type_identifier) @type
51(predefined_type) @type.builtin
52
53([
54 (identifier)
55 (shorthand_property_identifier)
56 (shorthand_property_identifier_pattern)
57 ] @constant
58 (#match? @constant "^_*[A-Z_][A-Z\\d_]*$"))
59
60; Literals
61
62(this) @keyword
63(super) @keyword
64
65[
66 (null)
67 (undefined)
68] @constant.builtin
69
70[
71 (true)
72 (false)
73] @boolean
74
75(comment) @comment
76
77[
78 (string)
79 (template_string)
80] @string
81
82(escape_sequence) @string.escape
83
84(regex) @string.regex
85(regex_flags) @keyword.regex
86(number) @number
87
88; Tokens
89
90[
91 ";"
92 "?."
93 "."
94 ","
95 ":"
96] @punctuation.delimiter
97
98[
99 "-"
100 "--"
101 "-="
102 "+"
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] @operator
144
145[
146 "("
147 ")"
148 "["
149 "]"
150 "{"
151 "}"
152] @punctuation.bracket
153
154(ternary_expression
155 [
156 "?"
157 ":"
158 ] @operator
159)
160
161[
162 "as"
163 "async"
164 "await"
165 "break"
166 "case"
167 "catch"
168 "class"
169 "const"
170 "continue"
171 "debugger"
172 "default"
173 "delete"
174 "do"
175 "else"
176 "export"
177 "extends"
178 "finally"
179 "for"
180 "from"
181 "function"
182 "get"
183 "if"
184 "import"
185 "in"
186 "instanceof"
187 "let"
188 "new"
189 "of"
190 "return"
191 "set"
192 "static"
193 "switch"
194 "target"
195 "throw"
196 "try"
197 "typeof"
198 "using"
199 "var"
200 "void"
201 "while"
202 "with"
203 "yield"
204] @keyword
205
206(template_substitution
207 "${" @punctuation.special
208 "}" @punctuation.special) @embedded
209
210(type_arguments
211 "<" @punctuation.bracket
212 ">" @punctuation.bracket)
213
214(decorator "@" @punctuation.special)
215
216; Keywords
217
218[ "abstract"
219 "declare"
220 "enum"
221 "export"
222 "implements"
223 "interface"
224 "keyof"
225 "namespace"
226 "private"
227 "protected"
228 "public"
229 "type"
230 "readonly"
231 "override"
232] @keyword
233
234; JSX elements
235(jsx_opening_element (identifier) @tag.jsx (#match? @tag.jsx "^[a-z][^.]*$"))
236(jsx_closing_element (identifier) @tag.jsx (#match? @tag.jsx "^[a-z][^.]*$"))
237(jsx_self_closing_element (identifier) @tag.jsx (#match? @tag.jsx "^[a-z][^.]*$"))
238
239(jsx_attribute (property_identifier) @attribute.jsx)
240(jsx_opening_element (["<" ">"]) @punctuation.bracket.jsx)
241(jsx_closing_element (["</" ">"]) @punctuation.bracket.jsx)
242(jsx_self_closing_element (["<" "/>"]) @punctuation.bracket.jsx)
243(jsx_attribute "=" @punctuation.delimiter.jsx)
244(jsx_text) @text.jsx