highlights.scm

  1(dotted_identifier_list) @string
  2
  3; Methods
  4; --------------------
  5(function_type
  6    name: (identifier) @function)
  7(super) @function
  8
  9; Annotations
 10; --------------------
 11(annotation
 12  name: (identifier) @attribute)
 13
 14; Operators and Tokens
 15; --------------------
 16(template_substitution
 17  "$" @punctuation.special
 18  "{" @punctuation.special
 19  "}" @punctuation.special
 20  ) @none
 21
 22(template_substitution
 23  "$" @punctuation.special
 24  (identifier_dollar_escaped) @variable
 25  ) @none
 26
 27(escape_sequence) @string.escape
 28
 29[
 30  "@"
 31  "=>"
 32  ".."
 33  "??"
 34  "=="
 35  "?"
 36  ":"
 37  "&&"
 38  "%"
 39  "<"
 40  ">"
 41  "="
 42  ">="
 43  "<="
 44  "||"
 45  (increment_operator)
 46  (is_operator)
 47  (prefix_operator)
 48  (equality_operator)
 49  (additive_operator)
 50  ] @operator
 51
 52[
 53  "("
 54  ")"
 55  "["
 56  "]"
 57  "{"
 58  "}"
 59  "<"
 60  ">"
 61  ]  @punctuation.bracket
 62
 63; Delimiters
 64; --------------------
 65[
 66  ";"
 67  "."
 68  ","
 69  ] @punctuation.delimiter
 70
 71; Types
 72; --------------------
 73(class_definition
 74  name: (identifier) @type)
 75(constructor_signature
 76  name: (identifier) @type)
 77(scoped_identifier
 78  scope: (identifier) @type)
 79(function_signature
 80  name: (identifier) @function)
 81(getter_signature
 82  (identifier) @function)
 83(setter_signature
 84  name: (identifier) @function)
 85(enum_declaration
 86  name: (identifier) @type)
 87(enum_constant
 88  name: (identifier) @type)
 89(type_identifier) @type
 90(void_type) @type
 91
 92((scoped_identifier
 93   scope: (identifier) @type
 94   name: (identifier) @type)
 95  (#match? @type "^[a-zA-Z]"))
 96
 97(type_identifier) @type
 98
 99; Variables
100; --------------------
101; var keyword
102(inferred_type) @keyword
103
104(const_builtin) @constant.builtin
105(final_builtin) @constant.builtin
106
107((identifier) @type
108  (#match? @type "^_?[A-Z]"))
109
110("Function" @type)
111
112; properties
113; TODO: add method/call_expression to grammar and
114; distinguish method call from variable access
115(unconditional_assignable_selector
116  (identifier) @property)
117
118; assignments
119(assignment_expression
120  left: (assignable_expression) @variable)
121
122(this) @variable.builtin
123
124; Literals
125; --------------------
126[
127  (hex_integer_literal)
128  (decimal_integer_literal)
129  (decimal_floating_point_literal)
130  ; TODO: inaccessible nodes
131  ; (octal_integer_literal)
132  ; (hex_floating_point_literal)
133  ] @number
134
135(symbol_literal) @symbol
136(string_literal) @string
137(true) @boolean
138(false) @boolean
139(null_literal) @constant.builtin
140
141(documentation_comment) @comment
142(comment) @comment
143
144; Keywords
145; --------------------
146["import" "library" "export"] @keyword.include
147
148; Reserved words (cannot be used as identifiers)
149; TODO: "rethrow" @keyword
150[
151  ; "assert"
152  (case_builtin)
153  "extension"
154  "on"
155  "class"
156  "enum"
157  "extends"
158  "in"
159  "is"
160  "new"
161  "return"
162  "super"
163  "with"
164  ] @keyword
165
166
167; Built in identifiers:
168; alone these are marked as keywords
169[
170  "abstract"
171  "as"
172  "async"
173  "async*"
174  "yield"
175  "sync*"
176  "await"
177  "covariant"
178  "deferred"
179  "dynamic"
180  "external"
181  "factory"
182  "get"
183  "implements"
184  "interface"
185  "library"
186  "operator"
187  "mixin"
188  "part"
189  "set"
190  "show"
191  "static"
192  "typedef"
193  ] @keyword
194
195; when used as an identifier:
196((identifier) @variable.builtin
197  (#vim-match? @variable.builtin "^(abstract|as|covariant|deferred|dynamic|export|external|factory|Function|get|implements|import|interface|library|operator|mixin|part|set|static|typedef)$"))
198
199["if" "else" "switch" "default"] @keyword
200
201[
202  "try"
203  "throw"
204  "catch"
205  "finally"
206  (break_statement)
207  ] @keyword
208
209["do" "while" "continue" "for"] @keyword