highlights.scm

  1(dotted_identifier_list) @string
  2
  3; Methods
  4; --------------------
  5(super) @function
  6
  7(function_expression_body (identifier) @type)
  8; ((identifier)(selector (argument_part)) @function)
  9
 10(((identifier) @function (#match? @function "^_?[a-z]"))
 11 . (selector . (argument_part))) @function
 12
 13; Annotations
 14; --------------------
 15(annotation
 16 name: (identifier) @attribute)
 17
 18; Operators and Tokens
 19; --------------------
 20(template_substitution
 21 "$" @punctuation.special
 22 "{" @punctuation.special
 23 "}" @punctuation.special) @none
 24
 25(template_substitution
 26 "$" @punctuation.special
 27 (identifier_dollar_escaped) @variable) @none
 28
 29(escape_sequence) @string.escape
 30
 31[
 32 "@"
 33 "=>"
 34 ".."
 35 "??"
 36 "=="
 37 "?"
 38 ":"
 39 "&&"
 40 "%"
 41 "<"
 42 ">"
 43 "="
 44 ">="
 45 "<="
 46 "||"
 47 (multiplicative_operator)
 48 (increment_operator)
 49 (is_operator)
 50 (prefix_operator)
 51 (equality_operator)
 52 (additive_operator)
 53 ] @operator
 54
 55[
 56 "("
 57 ")"
 58 "["
 59 "]"
 60 "{"
 61 "}"
 62 ] @punctuation.bracket
 63
 64; Delimiters
 65; --------------------
 66[
 67 ";"
 68 "."
 69 ","
 70 ] @punctuation.delimiter
 71
 72; Types
 73; --------------------
 74(class_definition
 75 name: (identifier) @type)
 76(constructor_signature
 77 name: (identifier) @type)
 78(scoped_identifier
 79 scope: (identifier) @type)
 80(function_signature
 81 name: (identifier) @function.method)
 82
 83(getter_signature
 84 (identifier) @function.method)
 85
 86(setter_signature
 87 name: (identifier) @function.method)
 88(enum_declaration
 89 name: (identifier) @type)
 90(enum_constant
 91 name: (identifier) @type)
 92(void_type) @type
 93
 94((scoped_identifier
 95  scope: (identifier) @type
 96  name: (identifier) @type)
 97 (#match? @type "^[a-zA-Z]"))
 98
 99(type_identifier) @type
100
101(type_alias
102 (type_identifier) @type.definition)
103
104; Variables
105; --------------------
106; var keyword
107(inferred_type) @keyword
108
109((identifier) @type
110 (#match? @type "^_?[A-Z].*[a-z]"))
111
112("Function" @type)
113
114; properties
115(unconditional_assignable_selector
116 (identifier) @property)
117
118(conditional_assignable_selector
119 (identifier) @property)
120
121; assignments
122(assignment_expression
123 left: (assignable_expression) @variable)
124
125(this) @variable.builtin
126
127; Parameters
128; --------------------
129(formal_parameter
130 name: (identifier) @variable.parameter)
131
132(named_argument
133 (label
134    (identifier) @variable.parameter))
135
136; Literals
137; --------------------
138[
139 (hex_integer_literal)
140 (decimal_integer_literal)
141 (decimal_floating_point_literal)
142 ; TODO: inaccessible nodes
143 ; (octal_integer_literal)
144 ; (hex_floating_point_literal)
145 ] @number
146
147(symbol_literal) @string.special.symbol
148
149(string_literal) @string
150(true) @boolean
151(false) @boolean
152(null_literal) @constant.builtin
153
154(comment) @comment
155
156(documentation_comment) @comment.documentation
157
158; Keywords
159; --------------------
160[
161 "import"
162 "library"
163 "export"
164 "as"
165 "show"
166 "hide"
167 ] @keyword.import
168
169; Reserved words (cannot be used as identifiers)
170[
171  (case_builtin)
172 "late"
173 "required"
174 "extension"
175 "on"
176 "class"
177 "enum"
178 "extends"
179 "in"
180 "is"
181 "new"
182 "super"
183 "with"
184 ] @keyword
185
186"return" @keyword.return
187
188; Built in identifiers:
189; alone these are marked as keywords
190[
191  "deferred"
192 "factory"
193 "get"
194 "implements"
195 "interface"
196 "library"
197 "operator"
198 "mixin"
199 "part"
200 "set"
201 "typedef"
202 ] @keyword
203
204[
205  "async"
206  "async*"
207  "sync*"
208  "await"
209  "yield"
210] @keyword.coroutine
211
212[
213 (const_builtin)
214 (final_builtin)
215 "abstract"
216  "covariant"
217 "dynamic"
218 "external"
219 "static"
220 "final"
221  "base"
222  "sealed"
223 ] @type.qualifier
224
225; when used as an identifier:
226((identifier) @variable.builtin
227 (#any-of? @variable.builtin
228           "abstract"
229           "as"
230           "covariant"
231           "deferred"
232           "dynamic"
233           "export"
234           "external"
235           "factory"
236           "Function"
237           "get"
238           "implements"
239           "import"
240           "interface"
241           "library"
242           "operator"
243           "mixin"
244           "part"
245           "set"
246           "static"
247           "typedef"))
248
249[
250  "if"
251  "else"
252  "switch"
253  "default"
254] @keyword.conditional
255
256[
257  "try"
258  "throw"
259  "catch"
260  "finally"
261  (break_statement)
262] @keyword.exception
263
264[
265  "do"
266  "while"
267  "continue"
268  "for"
269] @keyword.repeat