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