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