You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

203 lines
6.1KB

  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: ^\w*\b(library|import|part of|part|export)\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. - include: comments
  23. - match: \b(as|show|hide)\b
  24. scope: keyword.other.import.dart
  25. - include: comments
  26. - include: punctuation
  27. - include: annotations
  28. - include: keywords
  29. - include: constants-and-special-vars
  30. - include: strings
  31. annotations:
  32. - match: "@[a-zA-Z]+"
  33. scope: storage.type.annotation.dart
  34. comments:
  35. - match: /\*\*/
  36. scope: comment.block.empty.dart
  37. captures:
  38. 0: punctuation.definition.comment.dart
  39. - include: comments-doc-oldschool
  40. - include: comments-doc
  41. - include: comments-inline
  42. comments-doc:
  43. - match: ///
  44. scope: comment.block.documentation.dart
  45. comments-doc-oldschool:
  46. - match: /\*\*
  47. push:
  48. - meta_scope: comment.block.documentation.dart
  49. - match: \*/
  50. pop: true
  51. - include: dartdoc
  52. comments-inline:
  53. - match: /\*
  54. push:
  55. - meta_scope: comment.block.dart
  56. - match: \*/
  57. pop: true
  58. - match: ((//).*)$
  59. captures:
  60. 1: comment.line.double-slash.dart
  61. constants-and-special-vars:
  62. - match: (?<!\$)\b(true|false|null)\b(?!\$)
  63. scope: constant.language.dart
  64. - match: (?<!\$)\b(this|super)\b(?!\$)
  65. scope: variable.language.dart
  66. - match: '(?<!\$)\b((0(x|X)[0-9a-fA-F]*)|(([0-9]+\.?[0-9]*)|(\.[0-9]+))((e|E)(\+|-)?[0-9]+)?)\b(?!\$)'
  67. scope: constant.numeric.dart
  68. - match: "(?<![a-zA-Z0-9_$])[_$]*[A-Z][a-zA-Z0-9_$]*"
  69. scope: support.class.dart
  70. - match: '([_$]*[a-z][a-zA-Z0-9_$]*)(\(|\s+=>)'
  71. captures:
  72. 1: entity.name.function.dart
  73. dartdoc:
  74. - match: '(\[.*?\])'
  75. captures:
  76. 0: variable.name.source.dart
  77. - match: " .*"
  78. captures:
  79. 0: variable.name.source.dart
  80. - match: "```.*?$"
  81. push:
  82. - meta_content_scope: variable.other.source.dart
  83. - match: "```"
  84. pop: true
  85. - match: (`.*?`)
  86. captures:
  87. 0: variable.other.source.dart
  88. - match: (`.*?`)
  89. captures:
  90. 0: variable.other.source.dart
  91. - match: (\* (( ).*))$
  92. captures:
  93. 2: variable.other.source.dart
  94. - match: (\* .*)$
  95. keywords:
  96. - match: (?<!\$)\bas\b(?!\$)
  97. scope: keyword.cast.dart
  98. - match: (?<!\$)\b(try|on|catch|finally|throw|rethrow)\b(?!\$)
  99. scope: keyword.control.catch-exception.dart
  100. - match: (?<!\$)\b(break|case|continue|default|do|else|for|if|in|return|switch|while)\b(?!\$)
  101. scope: keyword.control.dart
  102. - match: (?<!\$)\b(sync(\*)?|async(\*)?|await|yield(\*)?)\b(?!\$)
  103. scope: keyword.control.dart
  104. - match: (?<!\$)\bassert\b(?!\$)
  105. scope: keyword.control.dart
  106. - match: (?<!\$)\b(new)\b(?!\$)
  107. scope: keyword.control.new.dart
  108. - match: (?<!\$)\b(abstract|class|enum|extends|external|factory|implements|get|mixin|native|operator|set|typedef|with)\b(?!\$)
  109. scope: keyword.declaration.dart
  110. - match: (?<!\$)\b(is\!?)\b(?!\$)
  111. scope: keyword.operator.dart
  112. - match: '\?|:'
  113. scope: keyword.operator.ternary.dart
  114. - match: (<<|>>>?|~|\^|\||&)
  115. scope: keyword.operator.bitwise.dart
  116. - match: ((&|\^|\||<<|>>>?)=)
  117. scope: keyword.operator.assignment.bitwise.dart
  118. - match: (=>)
  119. scope: keyword.operator.closure.dart
  120. - match: (==|!=|<=?|>=?)
  121. scope: keyword.operator.comparison.dart
  122. - match: '(([+*/%-]|\~)=)'
  123. scope: keyword.operator.assignment.arithmetic.dart
  124. - match: (=)
  125. scope: keyword.operator.assignment.dart
  126. - match: (\-\-|\+\+)
  127. scope: keyword.operator.increment-decrement.dart
  128. - match: (\-|\+|\*|\/|\~\/|%)
  129. scope: keyword.operator.arithmetic.dart
  130. - match: (!|&&|\|\|)
  131. scope: keyword.operator.logical.dart
  132. - match: (?<!\$)\b(static|final|const)\b(?!\$)
  133. scope: storage.modifier.dart
  134. - match: (?<!\$)\b(?:void|bool|num|int|double|dynamic|var)\b(?!\$)
  135. scope: storage.type.primitive.dart
  136. punctuation:
  137. - match: ","
  138. scope: punctuation.comma.dart
  139. - match: ;
  140. scope: punctuation.terminator.dart
  141. - match: \.
  142. scope: punctuation.dot.dart
  143. string-interp:
  144. - match: '\$((\w+)|\{([^{}]+)\})'
  145. captures:
  146. 2: variable.parameter.dart
  147. 3: variable.parameter.dart
  148. - match: \\.
  149. scope: constant.character.escape.dart
  150. strings:
  151. - match: (?<!r)"""
  152. push:
  153. - meta_scope: string.interpolated.triple.double.dart
  154. - match: '"""(?!")'
  155. pop: true
  156. - include: string-interp
  157. - match: (?<!r)'''
  158. push:
  159. - meta_scope: string.interpolated.triple.single.dart
  160. - match: "'''(?!')"
  161. pop: true
  162. - include: string-interp
  163. - match: r"""
  164. push:
  165. - meta_scope: string.quoted.triple.double.dart
  166. - match: '"""(?!")'
  167. pop: true
  168. - match: r'''
  169. push:
  170. - meta_scope: string.quoted.triple.single.dart
  171. - match: "'''(?!')"
  172. pop: true
  173. - match: (?<!\|r)"
  174. push:
  175. - meta_scope: string.interpolated.double.dart
  176. - match: '"'
  177. pop: true
  178. - match: \n
  179. scope: invalid.string.newline
  180. - include: string-interp
  181. - match: r"
  182. push:
  183. - meta_scope: string.quoted.double.dart
  184. - match: '"'
  185. pop: true
  186. - match: \n
  187. scope: invalid.string.newline
  188. - match: (?<!\|r)'
  189. push:
  190. - meta_scope: string.interpolated.single.dart
  191. - match: "'"
  192. pop: true
  193. - match: \n
  194. scope: invalid.string.newline
  195. - include: string-interp
  196. - match: r'
  197. push:
  198. - meta_scope: string.quoted.single.dart
  199. - match: "'"
  200. pop: true
  201. - match: \n
  202. scope: invalid.string.newline