highlights.scm

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