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[
108  (string)
109  (template_string)
110  (template_literal_type)
111] @string
112
113(escape_sequence) @string.escape
114
115(regex) @string.regex
116(regex_flags) @keyword.operator.regex
117(number) @number
118
119; Tokens
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  ">="
150  ">>"
151  ">>="
152  ">>>"
153  ">>>="
154  "~"
155  "^"
156  "&"
157  "|"
158  "^="
159  "&="
160  "|="
161  "&&"
162  "||"
163  "??"
164  "&&="
165  "||="
166  "??="
167] @operator
168
169(regex "/" @string.regex)
170
171(ternary_expression
172  [
173    "?"
174    ":"
175  ] @operator
176)
177
178[
179  ";"
180  "?."
181  "."
182  ","
183  ":"
184  "?"
185] @punctuation.delimiter
186
187[
188  "("
189  ")"
190  "["
191  "]"
192  "{"
193  "}"
194]  @punctuation.bracket
195
196(template_substitution
197  "${" @punctuation.special
198  "}" @punctuation.special) @embedded
199
200(template_type
201  "${" @punctuation.special
202  "}" @punctuation.special) @embedded
203
204(type_arguments
205  "<" @punctuation.bracket
206  ">" @punctuation.bracket)
207
208(decorator "@" @punctuation.special)
209
210; Keywords
211
212[
213  "abstract"
214  "as"
215  "async"
216  "await"
217  "break"
218  "case"
219  "catch"
220  "class"
221  "const"
222  "continue"
223  "debugger"
224  "declare"
225  "default"
226  "delete"
227  "do"
228  "else"
229  "enum"
230  "export"
231  "extends"
232  "finally"
233  "for"
234  "from"
235  "function"
236  "get"
237  "if"
238  "implements"
239  "import"
240  "in"
241  "infer"
242  "instanceof"
243  "interface"
244  "is"
245  "keyof"
246  "let"
247  "namespace"
248  "new"
249  "of"
250  "override"
251  "private"
252  "protected"
253  "public"
254  "readonly"
255  "return"
256  "satisfies"
257  "set"
258  "static"
259  "switch"
260  "target"
261  "throw"
262  "try"
263  "type"
264  "typeof"
265  "using"
266  "var"
267  "void"
268  "while"
269  "with"
270  "yield"
271] @keyword