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) @variable.special
63(super) @variable.special
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(number) @number
86
87; Tokens
88
89[
90 ";"
91 "?."
92 "."
93 ","
94 ":"
95] @punctuation.delimiter
96
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] @operator
143
144[
145 "("
146 ")"
147 "["
148 "]"
149 "{"
150 "}"
151] @punctuation.bracket
152
153[
154 "as"
155 "async"
156 "await"
157 "break"
158 "case"
159 "catch"
160 "class"
161 "const"
162 "continue"
163 "debugger"
164 "default"
165 "delete"
166 "do"
167 "else"
168 "export"
169 "extends"
170 "finally"
171 "for"
172 "from"
173 "function"
174 "get"
175 "if"
176 "import"
177 "in"
178 "instanceof"
179 "let"
180 "new"
181 "of"
182 "return"
183 "set"
184 "static"
185 "switch"
186 "target"
187 "throw"
188 "try"
189 "typeof"
190 "var"
191 "void"
192 "while"
193 "with"
194 "yield"
195] @keyword
196
197(template_substitution
198 "${" @punctuation.special
199 "}" @punctuation.special) @embedded
200
201(type_arguments
202 "<" @punctuation.bracket
203 ">" @punctuation.bracket)
204
205; Keywords
206
207[ "abstract"
208 "declare"
209 "enum"
210 "export"
211 "implements"
212 "interface"
213 "keyof"
214 "namespace"
215 "private"
216 "protected"
217 "public"
218 "type"
219 "readonly"
220 "override"
221] @keyword
222
223; JSX elements
224(jsx_opening_element (identifier) @tag (#match? @tag "^[a-z][^.]*$"))
225(jsx_closing_element (identifier) @tag (#match? @tag "^[a-z][^.]*$"))
226(jsx_self_closing_element (identifier) @tag (#match? @tag "^[a-z][^.]*$"))
227
228(jsx_attribute (property_identifier) @attribute)
229(jsx_opening_element (["<" ">"]) @punctuation.bracket)
230(jsx_closing_element (["</" ">"]) @punctuation.bracket)
231(jsx_self_closing_element (["<" "/>"]) @punctuation.bracket)