highlights.scm

  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(method_definition
 29    name: (property_identifier) @constructor
 30    (#eq? @constructor "constructor"))
 31
 32(pair
 33  key: (property_identifier) @function.method
 34  value: [(function_expression) (arrow_function)])
 35
 36(assignment_expression
 37  left: (member_expression
 38    property: (property_identifier) @function.method)
 39  right: [(function_expression) (arrow_function)])
 40
 41(variable_declarator
 42  name: (identifier) @function
 43  value: [(function_expression) (arrow_function)])
 44
 45(assignment_expression
 46  left: (identifier) @function
 47  right: [(function_expression) (arrow_function)])
 48
 49; Special identifiers
 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) @variable.special
 66(super) @variable.special
 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] @string
 84
 85(escape_sequence) @string.escape
 86
 87(regex) @string.regex
 88(regex_flags) @keyword.operator.regex
 89(number) @number
 90
 91; Tokens
 92
 93[
 94  ";"
 95  "?."
 96  "."
 97  ","
 98  ":"
 99] @punctuation.delimiter
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  "??="
146] @operator
147
148(regex "/" @string.regex)
149
150[
151  "("
152  ")"
153  "["
154  "]"
155  "{"
156  "}"
157]  @punctuation.bracket
158
159(ternary_expression
160  [
161    "?"
162    ":"
163  ] @operator
164)
165
166[
167  "as"
168  "async"
169  "await"
170  "break"
171  "case"
172  "catch"
173  "class"
174  "const"
175  "continue"
176  "debugger"
177  "default"
178  "delete"
179  "do"
180  "else"
181  "export"
182  "extends"
183  "finally"
184  "for"
185  "from"
186  "function"
187  "get"
188  "if"
189  "import"
190  "in"
191  "instanceof"
192  "let"
193  "new"
194  "of"
195  "return"
196  "set"
197  "static"
198  "switch"
199  "target"
200  "throw"
201  "try"
202  "typeof"
203  "using"
204  "var"
205  "void"
206  "while"
207  "with"
208  "yield"
209] @keyword
210
211(template_substitution
212  "${" @punctuation.special
213  "}" @punctuation.special) @embedded
214
215(type_arguments
216  "<" @punctuation.bracket
217  ">" @punctuation.bracket)
218
219(decorator "@" @punctuation.special)
220
221; Keywords
222
223[ "abstract"
224  "declare"
225  "enum"
226  "export"
227  "implements"
228  "interface"
229  "keyof"
230  "namespace"
231  "private"
232  "protected"
233  "public"
234  "type"
235  "readonly"
236  "override"
237] @keyword
238
239; JSX elements
240(jsx_opening_element (identifier) @tag.jsx (#match? @tag.jsx "^[a-z][^.]*$"))
241(jsx_closing_element (identifier) @tag.jsx (#match? @tag.jsx "^[a-z][^.]*$"))
242(jsx_self_closing_element (identifier) @tag.jsx (#match? @tag.jsx "^[a-z][^.]*$"))
243
244(jsx_attribute (property_identifier) @attribute.jsx)
245(jsx_opening_element (["<" ">"]) @punctuation.bracket.jsx)
246(jsx_closing_element (["</" ">"]) @punctuation.bracket.jsx)
247(jsx_self_closing_element (["<" "/>"]) @punctuation.bracket.jsx)
248(jsx_attribute "=" @punctuation.delimiter.jsx)
249(jsx_text) @text.jsx