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