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