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