highlights.scm

  1; Variables
  2
  3(identifier) @variable
  4
  5; Properties
  6
  7(property_identifier) @property
  8
  9; Function and method calls
 10
 11(call_expression
 12  function: (identifier) @function)
 13
 14(call_expression
 15  function: (member_expression
 16    property: (property_identifier) @function.method))
 17
 18; Function and method definitions
 19
 20(function
 21  name: (identifier) @function)
 22(function_declaration
 23  name: (identifier) @function)
 24(method_definition
 25  name: (property_identifier) @function.method)
 26
 27(pair
 28  key: (property_identifier) @function.method
 29  value: [(function) (arrow_function)])
 30
 31(assignment_expression
 32  left: (member_expression
 33    property: (property_identifier) @function.method)
 34  right: [(function) (arrow_function)])
 35
 36(variable_declarator
 37  name: (identifier) @function
 38  value: [(function) (arrow_function)])
 39
 40(assignment_expression
 41  left: (identifier) @function
 42  right: [(function) (arrow_function)])
 43
 44; Special identifiers
 45
 46((identifier) @constructor
 47 (#match? @constructor "^[A-Z]"))
 48
 49([
 50  (identifier)
 51  (shorthand_property_identifier)
 52  (shorthand_property_identifier_pattern)
 53 ] @constant
 54 (#match? @constant "^[A-Z_][A-Z\\d_]+$"))
 55
 56; Literals
 57
 58(this) @variable.special
 59(super) @variable.special
 60
 61[
 62  (true)
 63  (false)
 64  (null)
 65  (undefined)
 66] @constant.builtin
 67
 68(comment) @comment
 69
 70[
 71  (string)
 72  (template_string)
 73] @string
 74
 75(regex) @string.special
 76(number) @number
 77
 78; Tokens
 79
 80(template_substitution
 81  "${" @punctuation.special
 82  "}" @punctuation.special) @embedded
 83
 84[
 85  ";"
 86  "?."
 87  "."
 88  ","
 89  ":"
 90] @punctuation.delimiter
 91
 92[
 93  "-"
 94  "--"
 95  "-="
 96  "+"
 97  "++"
 98  "+="
 99  "*"
100  "*="
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] @operator
138
139[
140  "("
141  ")"
142  "["
143  "]"
144  "{"
145  "}"
146]  @punctuation.bracket
147
148[
149  "as"
150  "async"
151  "await"
152  "break"
153  "case"
154  "catch"
155  "class"
156  "const"
157  "continue"
158  "debugger"
159  "default"
160  "delete"
161  "do"
162  "else"
163  "export"
164  "extends"
165  "finally"
166  "for"
167  "from"
168  "function"
169  "get"
170  "if"
171  "import"
172  "in"
173  "instanceof"
174  "let"
175  "new"
176  "of"
177  "return"
178  "set"
179  "static"
180  "switch"
181  "target"
182  "throw"
183  "try"
184  "typeof"
185  "var"
186  "void"
187  "while"
188  "with"
189  "yield"
190] @keyword
191
192; Types
193
194(type_identifier) @type
195(predefined_type) @type.builtin
196
197((identifier) @type
198 (#match? @type "^[A-Z]"))
199
200(type_arguments
201  "<" @punctuation.bracket
202  ">" @punctuation.bracket)
203
204; Keywords
205
206[ "abstract"
207  "declare"
208  "enum"
209  "export"
210  "implements"
211  "interface"
212  "keyof"
213  "namespace"
214  "private"
215  "protected"
216  "public"
217  "type"
218  "readonly"
219  "override"
220] @keyword