on 855e438 help sign in
235 lines 3.7 kB history raw
1; JSX
2;----
4; Highlight component names differently
6(jsx_opening_element ((identifier) @constructor
7 (#match? @constructor "^[A-Z]")))
9; Handle the dot operator effectively - <My.Component>
10(jsx_opening_element ((nested_identifier (identifier) @tag (identifier) @constructor)))
12(jsx_closing_element ((identifier) @constructor
13 (#match? @constructor "^[A-Z]")))
15; Handle the dot operator effectively - </My.Component>
16(jsx_closing_element ((nested_identifier (identifier) @tag (identifier) @constructor)))
18(jsx_self_closing_element ((identifier) @constructor
19 (#match? @constructor "^[A-Z]")))
21; Handle the dot operator effectively - <My.Component />
22(jsx_self_closing_element ((nested_identifier (identifier) @tag (identifier) @constructor)))
24; TODO: also tag @punctuation.delimiter?
26(jsx_opening_element (identifier) @tag)
27(jsx_closing_element (identifier) @tag)
28(jsx_self_closing_element (identifier) @tag)
29(jsx_attribute (property_identifier) @variable.other.member)
31; Special identifiers
32;--------------------
34([
35 (identifier)
36 (shorthand_property_identifier)
37 (shorthand_property_identifier_pattern)
38 ] @constant
39 (#match? @constant "^[A-Z_][A-Z\\d_]+$"))
42((identifier) @constructor
43 (#match? @constructor "^[A-Z]"))
45((identifier) @variable.builtin
46 (#match? @variable.builtin "^(arguments|module|console|window|document)$")
47 (#is-not? local))
49((identifier) @function.builtin
50 (#eq? @function.builtin "require")
51 (#is-not? local))
53; Function and method definitions
54;--------------------------------
56(function
57 name: (identifier) @function)
58(function_declaration
59 name: (identifier) @function)
60(method_definition
61 name: (property_identifier) @function.method)
63(pair
64 key: (property_identifier) @function.method
65 value: [(function) (arrow_function)])
67(assignment_expression
68 left: (member_expression
69 property: (property_identifier) @function.method)
70 right: [(function) (arrow_function)])
72(variable_declarator
73 name: (identifier) @function
74 value: [(function) (arrow_function)])
76(assignment_expression
77 left: (identifier) @function
78 right: [(function) (arrow_function)])
80; Function and method calls
81;--------------------------
83(call_expression
84 function: (identifier) @function)
86(call_expression
87 function: (member_expression
88 property: (property_identifier) @function.method))
90; Variables
91;----------
93(identifier) @variable
95; Properties
96;-----------
98(property_identifier) @variable.other.member
100; Literals
101;---------
103(this) @variable.builtin
104(super) @variable.builtin
107 (true)
108 (false)
109 (null)
110 (undefined)
111] @constant.builtin
113(comment) @comment
116 (string)
117 (template_string)
118] @string
120(regex) @string.regexp
121(number) @constant.numeric.integer
123; Tokens
124;-------
126(template_substitution
127 "${" @punctuation.special
128 "}" @punctuation.special) @embedded
131 ";"
132 "?."
133 "."
134 ","
135] @punctuation.delimiter
138 "-"
139 "--"
140 "-="
141 "+"
142 "++"
143 "+="
144 "*"
145 "*="
146 "**"
147 "**="
148 "/"
149 "/="
150 "%"
151 "%="
152 "<"
153 "<="
154 "<<"
155 "<<="
156 "="
157 "=="
158 "==="
159 "!"
160 "!="
161 "!=="
162 "=>"
163 ">"
164 ">="
165 ">>"
166 ">>="
167 ">>>"
168 ">>>="
169 "~"
170 "^"
171 "&"
172 "|"
173 "^="
174 "&="
175 "|="
176 "&&"
177 "||"
178 "??"
179 "&&="
180 "||="
181 "??="
182] @operator
185 "("
186 ")"
187 "["
188 "]"
189 "{"
190 "}"
191] @punctuation.bracket
194 "as"
195 "async"
196 "await"
197 "break"
198 "case"
199 "catch"
200 "class"
201 "const"
202 "continue"
203 "debugger"
204 "default"
205 "delete"
206 "do"
207 "else"
208 "export"
209 "extends"
210 "finally"
211 "for"
212 "from"
213 "function"
214 "get"
215 "if"
216 "import"
217 "in"
218 "instanceof"
219 "let"
220 "new"
221 "of"
222 "return"
223 "set"
224 "static"
225 "switch"
226 "target"
227 "throw"
228 "try"
229 "typeof"
230 "var"
231 "void"
232 "while"
233 "with"
234 "yield"
235] @keyword