@@ -0,0 +1,369 @@
1+%YAML 1.2
2+---
3+# http://www.sublimetext.com/docs/3/syntax.html
4+name: Dart
5+file_extensions:
6+ - dart
7+scope: source.dart
8+contexts:
9+ main:
10+ - match: ^(#!.*)$
11+ scope: meta.preprocessor.script.dart
12+ - match: ^\s*\b(library|import|export|part of|part)\b
13+ captures:
14+ 0: keyword.other.import.dart
15+ push:
16+ - meta_scope: meta.declaration.dart
17+ - match: ;
18+ captures:
19+ 0: punctuation.terminator.dart
20+ pop: true
21+ - include: strings
22+ - match: \b(as|show|hide|deferred)\b
23+ scope: keyword.other.import.dart
24+ - include: comments
25+ - include: constants-and-special-vars
26+ - include: annotations
27+ - include: decl-typedef
28+ - include: decl-class
29+ - include: decl-enum
30+ - include: decl-function
31+ - include: keywords
32+ - include: strings
33+ annotations:
34+ - match: '^(?:\s*)((@)([a-zA-Z0-9_]+))'
35+ captures:
36+ 1: annotation.dart
37+ 2: entity.name.function.annotation.dart
38+ 3: support.type.dart
39+ comments:
40+ - match: /\*\*/
41+ scope: comment.block.empty.dart
42+ captures:
43+ 0: punctuation.definition.comment.dart
44+ - include: comments-inline
45+ comments-inline:
46+ - match: /\*
47+ push:
48+ - meta_scope: comment.block.dart
49+ - match: \*/
50+ pop: true
51+ - include: scope:text.dart-doccomments
52+ - match: (///)
53+ captures:
54+ 1: marker.dart
55+ push:
56+ - meta_scope: comment.line.triple-slash.dart
57+ - match: $
58+ pop: true
59+ - include: scope:text.dart-doccomments
60+ - match: (//)
61+ captures:
62+ 1: marker.dart
63+ push:
64+ - meta_scope: comment.line.double-slash.dart
65+ - match: $
66+ pop: true
67+ - include: scope:text.dart-doccomments
68+ constants-and-special-vars:
69+ - match: \b(true|false|null)\b
70+ scope: constant.language.dart
71+ - match: \b(this|super)\b
72+ scope: variable.language.dart
73+ - match: '\b((0(x|X)[0-9a-fA-F]*)|(([0-9]+\.?[0-9]*)|(\.[0-9]+))((e|E)(\+|-)?[0-9]+)?)\b'
74+ scope: constant.numeric.dart
75+ decl-class:
76+ - match: \bclass\b
77+ captures:
78+ 0: keyword.control.new.dart
79+ push:
80+ - meta_scope: meta.declaration.class.dart
81+ - match: "(?={)"
82+ pop: true
83+ - include: keywords
84+ - match: "[A-Za-z_][A-Za-z0-9_]*"
85+ scope: class.name.dart
86+ decl-enum:
87+ - match: \benum\b
88+ captures:
89+ 0: keyword.declaration.dart
90+ push:
91+ - meta_scope: meta.declaration.enum.dart
92+ - match: "(?={)"
93+ pop: true
94+ - include: keywords
95+ - match: "[A-Za-z_][A-Za-z0-9_]*"
96+ scope: enum.name.dart
97+ decl-function:
98+ - match: ^\s*(?:\b(void|bool|num|int|double|dynamic|var|String|List|Map)\b)\s+(get)\s+(\w+)\s+(?==>)
99+ comment: A getter with a primitive return type.
100+ scope: meta.declaration.function.dart
101+ captures:
102+ 1: storage.type.primitive.dart
103+ 2: keyword.declaration.dart
104+ 3: function.name.dart
105+ - match: ^\s*(?:\b(\w+)\b\s+)?(get)\s+(\w+)\s+(?==>)
106+ comment: A getter with a user-defined return type or no return type.
107+ scope: meta.declaration.function.dart
108+ captures:
109+ 1: type.user-defined.dart
110+ 2: keyword.declaration.dart
111+ 3: function.name.dart
112+ - match: ^\s*(set)\s+(\w+)(?=\()
113+ comment: A setter.
114+ captures:
115+ 1: keyword.declaration.dart
116+ 2: function.name.dart
117+ push:
118+ - meta_scope: meta.declaration.function.dart
119+ - match: \)
120+ pop: true
121+ - include: comments-inline
122+ - include: decl-function-parameter
123+ - include: strings
124+ - include: keywords
125+ - match: ^\s*(?:\b(void|bool|num|int|double|dynamic|var|String|List|Map)\b)\s+(\w+)(?=\()
126+ comment: A function with a primitive return type.
127+ captures:
128+ 1: storage.type.primitive.dart
129+ 2: function.name.dart
130+ push:
131+ - meta_scope: meta.declaration.function.dart
132+ - match: \)
133+ pop: true
134+ - include: comments-inline
135+ - include: decl-function-parameter
136+ - include: strings
137+ - include: keywords
138+ - match: ^\s*(?:\b(return)\b)\s+(\w+)(?=\()
139+ comment: A function invocation after 'return'
140+ captures:
141+ 1: keyword.control.dart
142+ 2: function.name.dart
143+ push:
144+ - meta_scope: meta.invocation.function.dart
145+ - match: \)
146+ pop: true
147+ - include: comments-inline
148+ - include: decl-function-parameter
149+ - include: strings
150+ - include: keywords
151+ - match: ^\s*\b(new)\b\s+(\w+)(?=\()
152+ comment: A class instantiation after 'new'
153+ captures:
154+ 1: keyword.declaration.dart
155+ 2: function.name.dart
156+ push:
157+ - meta_scope: meta.invocation.function.dart
158+ - match: \)
159+ pop: true
160+ - include: comments-inline
161+ - include: decl-function-parameter
162+ - include: strings
163+ - include: keywords
164+ decl-function-parameter:
165+ - include: constants-and-special-vars
166+ - match: (?:\b(void|bool|num|int|double|dynamic|var|String|List|Map)\b)\s+(\w+)(?=\()
167+ comment: A function with a primitive return type.
168+ captures:
169+ 1: storage.type.primitive.dart
170+ 2: function.name.dart
171+ push:
172+ - meta_scope: meta.parameter.function.dart
173+ - match: \)
174+ pop: true
175+ - include: decl-function-parameter
176+ - include: strings
177+ - include: keywords
178+ - match: \b(new)\b\s+(\w+)(?=\()
179+ comment: A class instantiation after 'new'
180+ captures:
181+ 1: keyword.declaration.dart
182+ 2: function.name.dart
183+ push:
184+ - meta_scope: meta.invocation.function.dart
185+ - match: \)
186+ pop: true
187+ - include: decl-function-parameter
188+ - include: strings
189+ - include: keywords
190+ - match: (?:\b(\w+)\b)\s+(\w+)(?=\()
191+ comment: A function with a user-defined return type.
192+ captures:
193+ 1: type.user-defined.dart
194+ 2: function.name.dart
195+ push:
196+ - meta_scope: meta.parameter.function.dart
197+ - match: \)
198+ pop: true
199+ - include: decl-function-parameter
200+ - include: strings
201+ - include: keywords
202+ - match: (\w+)(?=\()
203+ comment: A function with no return type.
204+ captures:
205+ 1: function.name.dart
206+ push:
207+ - meta_scope: meta.parameter.function.dart
208+ - match: \)
209+ pop: true
210+ - include: decl-function-parameter
211+ - include: strings
212+ - include: keywords
213+ decl-typedef:
214+ - match: typedef
215+ captures:
216+ 0: keyword.control.new.dart
217+ push:
218+ - meta_scope: meta.declaration.typedef.dart
219+ - match: ;
220+ captures:
221+ 0: punctuation.terminator.dart
222+ pop: true
223+ - match: '(?:\b(void|bool|num|int|double|dynamic|var|String|List|Map)\b|([a-zA-Z_][a-zA-Z0-9_]*))\s+([a-zA-Z_][a-zA-Z0-9_]+)'
224+ captures:
225+ 1: storage.type.primitive.dart
226+ 2: typedef.return.dart
227+ 3: typedef.name.dart
228+ - match: \(
229+ push:
230+ - meta_scope: typedef.params.dart
231+ - match: \)
232+ pop: true
233+ - include: keywords
234+ keywords:
235+ - match: \bassert\b
236+ scope: keyword.control.assert.dart
237+ - match: \bas\b
238+ scope: keyword.cast.dart
239+ - match: \b(try|catch|finally|throw|on|rethrow)\b
240+ scope: keyword.control.catch-exception.dart
241+ - match: \s+\?\s+|\s+:\s+
242+ scope: keyword.control.ternary.dart
243+ - match: \b(break|case|continue|default|do|else|for|if|in|return|switch|while)\b
244+ scope: keyword.control.dart
245+ - match: \b(async\*|async|await\*|await|yield)\b
246+ scope: keyword.control.async.dart
247+ - match: \b(new)\b
248+ scope: keyword.control.new.dart
249+ - match: \b(abstract|extends|external|factory|implements|with|interface|get|native|operator|set|typedef)\b
250+ scope: keyword.declaration.dart
251+ - match: \b(is\!?)\b
252+ scope: keyword.operator.dart
253+ - match: (<<|>>>?|~|\^|\||&)
254+ scope: keyword.operator.bitwise.dart
255+ - match: ((&|\^|\||<<|>>>?)=)
256+ scope: keyword.operator.assignment.bitwise.dart
257+ - match: (===?|!==?|<=?|>=?)
258+ scope: keyword.operator.comparison.dart
259+ - match: '(([+*/%-]|\~)=)'
260+ scope: keyword.operator.assignment.arithmetic.dart
261+ - match: (=)
262+ scope: keyword.operator.assignment.dart
263+ - match: (\-\-|\+\+)
264+ scope: keyword.operator.increment-decrement.dart
265+ - match: (\-|\+|\*|\/|\~\/|%)
266+ scope: keyword.operator.arithmetic.dart
267+ - match: (!|&&|\|\|)
268+ scope: keyword.operator.logical.dart
269+ - match: ;
270+ scope: punctuation.terminator.dart
271+ - match: \b(static|final|const)\b
272+ scope: storage.modifier.dart
273+ - match: \b(?:void|bool|num|int|double|dynamic|var|String|List|Map)\b
274+ scope: storage.type.primitive.dart
275+ regexp:
276+ - match: '\\[^''"]'
277+ scope: constant.character.escaped.regex.dart
278+ - match: \(
279+ push:
280+ - meta_content_scope: meta.capture.regex.dart
281+ - match: \)
282+ pop: true
283+ - match: \?(:|=|!)
284+ scope: ignore.capture.regex.dart
285+ - match: \*|\+|\?|\.|\|
286+ scope: keyword.other.regex.dart
287+ - match: \^|\$
288+ scope: keyword.other.regex.dart
289+ - match: \.
290+ scope: constant.other.regex.dart
291+ - match: '\[(\^)?'
292+ captures:
293+ 1: keyword.other.negation.regex.dart
294+ push:
295+ - meta_scope: constant.character.range.regex.dart
296+ - match: '\]'
297+ pop: true
298+ - match: '\\[^"'']'
299+ scope: constant.character.escaped.regex.dart
300+ - match: '\{(?:\d+)?,(?:\d+)?\}'
301+ scope: keyword.other.regex.dart
302+ string-interp:
303+ - match: '(\$)(\{)'
304+ captures:
305+ 1: keyword.other.dart
306+ 2: keyword.other.dart
307+ push:
308+ - meta_scope: interpolation.dart
309+ - meta_content_scope: source.dart
310+ - match: '(\})'
311+ captures:
312+ 1: keyword.other.dart
313+ pop: true
314+ - include: main
315+ - match: (\$)(\w+)
316+ captures:
317+ 1: keyword.other.dart
318+ 2: variable.parameter.dart
319+ - match: \\.
320+ scope: constant.character.escape.dart
321+ strings:
322+ - match: (?<!r)"""
323+ push:
324+ - meta_scope: string.interpolated.triple.double.dart
325+ - match: '"""(?!")'
326+ pop: true
327+ - include: string-interp
328+ - match: (?<!r)'''
329+ push:
330+ - meta_scope: string.interpolated.triple.single.dart
331+ - match: "'''(?!')"
332+ pop: true
333+ - include: string-interp
334+ - match: r"""
335+ push:
336+ - meta_scope: string.quoted.triple.double.dart
337+ - match: '"""(?!")'
338+ pop: true
339+ - match: r'''
340+ push:
341+ - meta_scope: string.quoted.triple.single.dart
342+ - match: "'''(?!')"
343+ pop: true
344+ - match: (?<!\\|r)"
345+ push:
346+ - meta_scope: string.interpolated.double.dart
347+ - match: '"'
348+ pop: true
349+ - match: \n
350+ scope: invalid.string.newline
351+ - include: string-interp
352+ - match: r"
353+ push:
354+ - meta_scope: string.quoted.double.dart
355+ - match: '"'
356+ pop: true
357+ - include: regexp
358+ - match: (?<!\|r)'
359+ push:
360+ - meta_scope: string.interpolated.single.dart
361+ - match: "'"
362+ pop: true
363+ - include: string-interp
364+ - match: r'
365+ push:
366+ - meta_scope: string.quoted.single.dart
367+ - match: "'"
368+ pop: true
369+ - include: regexp