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