Skip to content

Instantly share code, notes, and snippets.

@czoins
Last active February 1, 2024 09:53
Show Gist options
  • Save czoins/dba80bd052156f03999da551eb94c664 to your computer and use it in GitHub Desktop.
Save czoins/dba80bd052156f03999da551eb94c664 to your computer and use it in GitHub Desktop.
Dart syntax highlighting for Sublime Text ported from VS Code's Dart plugin (https://github.com/Dart-Code/Dart-Code/blob/master/syntaxes/dart.json). Place in "Sublime Text 3\Packages\User" or "Sublime Text\Packages\User". Create the folder "User" if it doesn't exist. Check "https://www.sublimetext.com/docs/side_by_side.html" if you don't know wh…
<plist version="1.0">
<dict>
<key>name</key>
<string>Dart</string>
<key>fileTypes</key>
<array>
<string>dart</string>
</array>
<key>scopeName</key>
<string>source.dart</string>
<key>foldingStartMarker</key>
<string>\{\s*$</string>
<key>foldingStopMarker</key>
<string>^\s*\}</string>
<key>patterns</key>
<array>
<dict>
<key>name</key>
<string>meta.preprocessor.script.dart</string>
<key>match</key>
<string>^(#!.*)$</string>
</dict>
<dict>
<key>begin</key>
<string>^\w*\b(library|import|part of|part|export)\b</string>
<key>beginCaptures</key>
<dict>
<key>0</key>
<dict>
<key>name</key>
<string>keyword.other.import.dart</string>
</dict>
</dict>
<key>end</key>
<string>;</string>
<key>endCaptures</key>
<dict>
<key>0</key>
<dict>
<key>name</key>
<string>punctuation.terminator.dart</string>
</dict>
</dict>
<key>name</key>
<string>meta.declaration.dart</string>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#strings</string>
</dict>
<dict>
<key>include</key>
<string>#comments</string>
</dict>
<dict>
<key>name</key>
<string>keyword.other.import.dart</string>
<key>match</key>
<string>\b(as|show|hide)\b</string>
</dict>
<dict>
<key>name</key>
<string>keyword.control.dart</string>
<key>match</key>
<string>\b(if)\b</string>
</dict>
</array>
</dict>
<dict>
<key>include</key>
<string>#comments</string>
</dict>
<dict>
<key>include</key>
<string>#punctuation</string>
</dict>
<dict>
<key>include</key>
<string>#annotations</string>
</dict>
<dict>
<key>include</key>
<string>#keywords</string>
</dict>
<dict>
<key>include</key>
<string>#constants-and-special-vars</string>
</dict>
<dict>
<key>include</key>
<string>#strings</string>
</dict>
</array>
<key>repository</key>
<dict>
<key>dartdoc</key>
<dict>
<key>patterns</key>
<array>
<dict>
<key>match</key>
<string>(\[.*?\])</string>
<key>captures</key>
<dict>
<key>0</key>
<dict>
<key>name</key>
<string>variable.name.source.dart</string>
</dict>
</dict>
</dict>
<dict>
<key>match</key>
<string>^ {4,}(?![ \*]).*</string>
<key>captures</key>
<dict>
<key>0</key>
<dict>
<key>name</key>
<string>variable.name.source.dart</string>
</dict>
</dict>
</dict>
<dict>
<key>begin</key>
<string>```.*?$</string>
<key>contentName</key>
<string>variable.other.source.dart</string>
<key>end</key>
<string>```</string>
</dict>
<dict>
<key>match</key>
<string>(`.*?`)</string>
<key>captures</key>
<dict>
<key>0</key>
<dict>
<key>name</key>
<string>variable.other.source.dart</string>
</dict>
</dict>
</dict>
<dict>
<key>match</key>
<string>(`.*?`)</string>
<key>captures</key>
<dict>
<key>0</key>
<dict>
<key>name</key>
<string>variable.other.source.dart</string>
</dict>
</dict>
</dict>
<dict>
<key>match</key>
<string>(\* (( ).*))$</string>
<key>captures</key>
<dict>
<key>2</key>
<dict>
<key>name</key>
<string>variable.other.source.dart</string>
</dict>
</dict>
</dict>
</array>
</dict>
<key>comments</key>
<dict>
<key>patterns</key>
<array>
<dict>
<key>name</key>
<string>comment.block.empty.dart</string>
<key>match</key>
<string>/\*\*/</string>
<key>captures</key>
<dict>
<key>0</key>
<dict>
<key>name</key>
<string>punctuation.definition.comment.dart</string>
</dict>
</dict>
</dict>
<dict>
<key>include</key>
<string>#comments-doc-oldschool</string>
</dict>
<dict>
<key>include</key>
<string>#comments-doc</string>
</dict>
<dict>
<key>include</key>
<string>#comments-inline</string>
</dict>
</array>
</dict>
<key>comments-doc-oldschool</key>
<dict>
<key>patterns</key>
<array>
<dict>
<key>begin</key>
<string>/\*\*</string>
<key>end</key>
<string>\*/</string>
<key>name</key>
<string>comment.block.documentation.dart</string>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#comments-doc-oldschool</string>
</dict>
<dict>
<key>include</key>
<string>#comments-block</string>
</dict>
<dict>
<key>include</key>
<string>#dartdoc</string>
</dict>
</array>
</dict>
</array>
</dict>
<key>comments-doc</key>
<dict>
<key>patterns</key>
<array>
<dict>
<key>begin</key>
<string>///</string>
<key>while</key>
<string>^\s*///</string>
<key>end</key>
<string>^\s*///</string>
<key>name</key>
<string>comment.block.documentation.dart</string>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#dartdoc</string>
</dict>
</array>
</dict>
</array>
</dict>
<key>comments-inline</key>
<dict>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#comments-block</string>
</dict>
<dict>
<key>match</key>
<string>((//).*)$</string>
<key>captures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>comment.line.double-slash.dart</string>
</dict>
</dict>
</dict>
</array>
</dict>
<key>comments-block</key>
<dict>
<key>patterns</key>
<array>
<dict>
<key>begin</key>
<string>/\*</string>
<key>end</key>
<string>\*/</string>
<key>name</key>
<string>comment.block.dart</string>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#comments-block</string>
</dict>
</array>
</dict>
</array>
</dict>
<key>annotations</key>
<dict>
<key>patterns</key>
<array>
<dict>
<key>name</key>
<string>storage.type.annotation.dart</string>
<key>match</key>
<string>@[a-zA-Z]+</string>
</dict>
</array>
</dict>
<key>constants-and-special-vars</key>
<dict>
<key>patterns</key>
<array>
<dict>
<key>name</key>
<string>constant.language.dart</string>
<key>match</key>
<string>(?&lt;!\$)\b(true|false|null)\b(?!\$)</string>
</dict>
<dict>
<key>name</key>
<string>variable.language.dart</string>
<key>match</key>
<string>(?&lt;!\$)\b(this|super)\b(?!\$)</string>
</dict>
<dict>
<key>name</key>
<string>constant.numeric.dart</string>
<key>match</key>
<string>(?&lt;!\$)\b((0(x|X)[0-9a-fA-F]*)|(([0-9]+\.?[0-9]*)|(\.[0-9]+))((e|E)(\+|-)?[0-9]+)?)\b(?!\$)</string>
</dict>
<dict>
<key>include</key>
<string>#class-identifier</string>
</dict>
<dict>
<key>include</key>
<string>#function-identifier</string>
</dict>
</array>
</dict>
<key>class-identifier</key>
<dict>
<key>patterns</key>
<array>
<dict>
<key>match</key>
<string>(?&lt;![a-zA-Z0-9_$])([_$]*[A-Z][a-zA-Z0-9_$]*(&lt;(?:[a-zA-Z0-9_$&lt;&gt;?]|,\s*|\s+extends\s+)+&gt;)?|bool\b|num\b|int\b|double\b|dynamic\b|(void)\b)</string>
<key>captures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>support.class.dart</string>
</dict>
<key>2</key>
<dict>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#type-args</string>
</dict>
</array>
</dict>
<key>3</key>
<dict>
<key>name</key>
<string>storage.type.primitive.dart</string>
</dict>
</dict>
</dict>
</array>
</dict>
<key>function-identifier</key>
<dict>
<key>patterns</key>
<array>
<dict>
<key>match</key>
<string>([_$]*[a-z][a-zA-Z0-9_$]*)(&lt;(?:[a-zA-Z0-9_$&lt;&gt;?]|,\s*|\s+extends\s+)+&gt;)?(\(|\s+=&gt;)</string>
<key>captures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>entity.name.function.dart</string>
</dict>
<key>2</key>
<dict>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#type-args</string>
</dict>
</array>
</dict>
</dict>
</dict>
</array>
</dict>
<key>type-args</key>
<dict>
<key>begin</key>
<string>(&lt;)</string>
<key>beginCaptures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>other.source.dart</string>
</dict>
</dict>
<key>end</key>
<string>(&gt;)</string>
<key>endCaptures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>other.source.dart</string>
</dict>
</dict>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#class-identifier</string>
</dict>
<dict>
<key>match</key>
<string>[\s,]+</string>
</dict>
<dict>
<key>name</key>
<string>keyword.declaration.dart</string>
<key>match</key>
<string>extends</string>
</dict>
</array>
</dict>
<key>keywords</key>
<dict>
<key>patterns</key>
<array>
<dict>
<key>name</key>
<string>keyword.cast.dart</string>
<key>match</key>
<string>(?&lt;!\$)\bas\b(?!\$)</string>
</dict>
<dict>
<key>name</key>
<string>keyword.control.catch-exception.dart</string>
<key>match</key>
<string>(?&lt;!\$)\b(try|on|catch|finally|throw|rethrow)\b(?!\$)</string>
</dict>
<dict>
<key>name</key>
<string>keyword.control.dart</string>
<key>match</key>
<string>(?&lt;!\$)\b(break|case|continue|default|do|else|for|if|in|return|switch|while)\b(?!\$)</string>
</dict>
<dict>
<key>name</key>
<string>keyword.control.dart</string>
<key>match</key>
<string>(?&lt;!\$)\b(sync(\*)?|async(\*)?|await|yield(\*)?)\b(?!\$)</string>
</dict>
<dict>
<key>name</key>
<string>keyword.control.dart</string>
<key>match</key>
<string>(?&lt;!\$)\bassert\b(?!\$)</string>
</dict>
<dict>
<key>name</key>
<string>keyword.control.new.dart</string>
<key>match</key>
<string>(?&lt;!\$)\b(new)\b(?!\$)</string>
</dict>
<dict>
<key>name</key>
<string>keyword.declaration.dart</string>
<key>match</key>
<string>(?&lt;!\$)\b(abstract|class|enum|extends|extension|external|factory|implements|get|mixin|native|operator|set|typedef|with|covariant)\b(?!\$)</string>
</dict>
<dict>
<key>name</key>
<string>keyword.operator.dart</string>
<key>match</key>
<string>(?&lt;!\$)\b(is\!?)\b(?!\$)</string>
</dict>
<dict>
<key>name</key>
<string>keyword.operator.ternary.dart</string>
<key>match</key>
<string>\?|:</string>
</dict>
<dict>
<key>name</key>
<string>keyword.operator.bitwise.dart</string>
<key>match</key>
<string>(&lt;&lt;|&gt;&gt;&gt;?|~|\^|\||&amp;)</string>
</dict>
<dict>
<key>name</key>
<string>keyword.operator.assignment.bitwise.dart</string>
<key>match</key>
<string>((&amp;|\^|\||&lt;&lt;|&gt;&gt;&gt;?)=)</string>
</dict>
<dict>
<key>name</key>
<string>keyword.operator.closure.dart</string>
<key>match</key>
<string>(=&gt;)</string>
</dict>
<dict>
<key>name</key>
<string>keyword.operator.comparison.dart</string>
<key>match</key>
<string>(==|!=|&lt;=?|&gt;=?)</string>
</dict>
<dict>
<key>name</key>
<string>keyword.operator.assignment.arithmetic.dart</string>
<key>match</key>
<string>(([+*/%-]|\~)=)</string>
</dict>
<dict>
<key>name</key>
<string>keyword.operator.assignment.dart</string>
<key>match</key>
<string>(=)</string>
</dict>
<dict>
<key>name</key>
<string>keyword.operator.increment-decrement.dart</string>
<key>match</key>
<string>(\-\-|\+\+)</string>
</dict>
<dict>
<key>name</key>
<string>keyword.operator.arithmetic.dart</string>
<key>match</key>
<string>(\-|\+|\*|\/|\~\/|%)</string>
</dict>
<dict>
<key>name</key>
<string>keyword.operator.logical.dart</string>
<key>match</key>
<string>(!|&amp;&amp;|\|\|)</string>
</dict>
<dict>
<key>name</key>
<string>storage.modifier.dart</string>
<key>match</key>
<string>(?&lt;!\$)\b(static|final|const|required|late)\b(?!\$)</string>
</dict>
<dict>
<key>name</key>
<string>storage.type.primitive.dart</string>
<key>match</key>
<string>(?&lt;!\$)\b(?:void|var)\b(?!\$)</string>
</dict>
</array>
</dict>
<key>string-interp</key>
<dict>
<key>patterns</key>
<array>
<dict>
<key>match</key>
<string>\$([a-zA-Z0-9_]+)</string>
<key>captures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>variable.parameter.dart</string>
</dict>
</dict>
</dict>
<dict>
<key>begin</key>
<string>\$\{</string>
<key>end</key>
<string>\}</string>
<key>name</key>
<string>string.interpolated.expression.dart</string>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#constants-and-special-vars</string>
<key>name</key>
<string>variable.parameter.dart</string>
</dict>
<dict>
<key>include</key>
<string>#strings</string>
</dict>
<dict>
<key>name</key>
<string>variable.parameter.dart</string>
<key>match</key>
<string>[a-zA-Z0-9_]+</string>
</dict>
</array>
</dict>
<dict>
<key>name</key>
<string>constant.character.escape.dart</string>
<key>match</key>
<string>\\.</string>
</dict>
</array>
</dict>
<key>strings</key>
<dict>
<key>patterns</key>
<array>
<dict>
<key>begin</key>
<string>(?&lt;!r)"""</string>
<key>end</key>
<string>"""(?!")</string>
<key>name</key>
<string>string.interpolated.triple.double.dart</string>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#string-interp</string>
</dict>
</array>
</dict>
<dict>
<key>begin</key>
<string>(?&lt;!r)'''</string>
<key>end</key>
<string>'''(?!')</string>
<key>name</key>
<string>string.interpolated.triple.single.dart</string>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#string-interp</string>
</dict>
</array>
</dict>
<dict>
<key>begin</key>
<string>r"""</string>
<key>end</key>
<string>"""(?!")</string>
<key>name</key>
<string>string.quoted.triple.double.dart</string>
</dict>
<dict>
<key>begin</key>
<string>r'''</string>
<key>end</key>
<string>'''(?!')</string>
<key>name</key>
<string>string.quoted.triple.single.dart</string>
</dict>
<dict>
<key>begin</key>
<string>(?&lt;!\|r)"</string>
<key>end</key>
<string>"</string>
<key>name</key>
<string>string.interpolated.double.dart</string>
<key>patterns</key>
<array>
<dict>
<key>name</key>
<string>invalid.string.newline</string>
<key>match</key>
<string>\n</string>
</dict>
<dict>
<key>include</key>
<string>#string-interp</string>
</dict>
</array>
</dict>
<dict>
<key>begin</key>
<string>r"</string>
<key>end</key>
<string>"</string>
<key>name</key>
<string>string.quoted.double.dart</string>
<key>patterns</key>
<array>
<dict>
<key>name</key>
<string>invalid.string.newline</string>
<key>match</key>
<string>\n</string>
</dict>
</array>
</dict>
<dict>
<key>begin</key>
<string>(?&lt;!\|r)'</string>
<key>end</key>
<string>'</string>
<key>name</key>
<string>string.interpolated.single.dart</string>
<key>patterns</key>
<array>
<dict>
<key>name</key>
<string>invalid.string.newline</string>
<key>match</key>
<string>\n</string>
</dict>
<dict>
<key>include</key>
<string>#string-interp</string>
</dict>
</array>
</dict>
<dict>
<key>begin</key>
<string>r'</string>
<key>end</key>
<string>'</string>
<key>name</key>
<string>string.quoted.single.dart</string>
<key>patterns</key>
<array>
<dict>
<key>name</key>
<string>invalid.string.newline</string>
<key>match</key>
<string>\n</string>
</dict>
</array>
</dict>
</array>
</dict>
<key>punctuation</key>
<dict>
<key>patterns</key>
<array>
<dict>
<key>name</key>
<string>punctuation.comma.dart</string>
<key>match</key>
<string>,</string>
</dict>
<dict>
<key>name</key>
<string>punctuation.terminator.dart</string>
<key>match</key>
<string>;</string>
</dict>
<dict>
<key>name</key>
<string>punctuation.dot.dart</string>
<key>match</key>
<string>\.</string>
</dict>
</array>
</dict>
</dict>
</dict>
</plist>
@guplem
Copy link

guplem commented Nov 26, 2021

I thought it was not possible because the instructions say to place it in "Sublime Text 3\Packages\User" I do not have the "Sublime Text 3" folder, just "Sublime Text" and then, in packages I do not have a "User" folder, I had to create it. I thought that it was incompatible with Sublime Text 4 because of the differences.

I created the "User" folder, and it works. So, my bad! Thank you very much for your time!

Maybe, if you want, you can update the text to say "create the 'User' folder if it does not exist" so, in case some people with limited intelligence (such as me) do not understand how to follow the instructions.

Thank you for your time again!

@czoins
Copy link
Author

czoins commented Nov 26, 2021

Thanks for the input, I updated the instructions.
You might want to update the file, as I just updated it to the latest version.

@guplem
Copy link

guplem commented Nov 26, 2021

Thanks for the input, I updated the instructions. You might want to update the file, as I just updated it to the latest version.

Thanks!!!

@tsavo-at-pieces
Copy link

Here is the converted version!

%YAML 1.2
---
# http://www.sublimetext.com/docs/syntax.html
name: Dart
file_extensions:
  - dart
scope: source.dart
contexts:
  main:
    - match: ^(#!.*)$
      scope: meta.preprocessor.script.dart
    - match: ^\w*\b(library|import|part of|part|export)\b
      captures:
        0: keyword.other.import.dart
      push:
        - meta_scope: meta.declaration.dart
        - match: ;
          captures:
            0: punctuation.terminator.dart
          pop: true
        - include: strings
        - include: comments
        - match: \b(as|show|hide)\b
          scope: keyword.other.import.dart
        - match: \b(if)\b
          scope: keyword.control.dart
    - include: comments
    - include: punctuation
    - include: annotations
    - include: keywords
    - include: constants-and-special-vars
    - include: strings
  annotations:
    - match: '@[a-zA-Z]+'
      scope: storage.type.annotation.dart
  class-identifier:
    - match: '(?<![a-zA-Z0-9_$])([_$]*[A-Z][a-zA-Z0-9_$]*(<(?:[a-zA-Z0-9_$<>?]|,\s*|\s+extends\s+)+>)?|bool\b|num\b|int\b|double\b|dynamic\b|(void)\b)'
      captures:
        1: support.class.dart
        3: storage.type.primitive.dart
  comments:
    - match: /\*\*/
      scope: comment.block.empty.dart
      captures:
        0: punctuation.definition.comment.dart
    - include: comments-doc-oldschool
    - include: comments-doc
    - include: comments-inline
  comments-block:
    - match: /\*
      push:
        - meta_scope: comment.block.dart
        - match: \*/
          pop: true
        - include: comments-block
  comments-doc:
    - match: ///
      push:
        - meta_scope: comment.block.documentation.dart
        - match: ^\s*///
          pop: true
        - include: dartdoc
  comments-doc-oldschool:
    - match: /\*\*
      push:
        - meta_scope: comment.block.documentation.dart
        - match: \*/
          pop: true
        - include: comments-doc-oldschool
        - include: comments-block
        - include: dartdoc
  comments-inline:
    - include: comments-block
    - match: ((//).*)$
      captures:
        1: comment.line.double-slash.dart
  constants-and-special-vars:
    - match: (?<!\$)\b(true|false|null)\b(?!\$)
      scope: constant.language.dart
    - match: (?<!\$)\b(this|super)\b(?!\$)
      scope: variable.language.dart
    - match: '(?<!\$)\b((0(x|X)[0-9a-fA-F]*)|(([0-9]+\.?[0-9]*)|(\.[0-9]+))((e|E)(\+|-)?[0-9]+)?)\b(?!\$)'
      scope: constant.numeric.dart
    - include: class-identifier
    - include: function-identifier
  dartdoc:
    - match: '(\[.*?\])'
      captures:
        0: variable.name.source.dart
    - match: '^ {4,}(?![ \*]).*'
      captures:
        0: variable.name.source.dart
    - match: '```.*?$'
      push:
        - meta_content_scope: variable.other.source.dart
        - match: '```'
          pop: true
    - match: (`.*?`)
      captures:
        0: variable.other.source.dart
    - match: (`.*?`)
      captures:
        0: variable.other.source.dart
    - match: (\* ((    ).*))$
      captures:
        2: variable.other.source.dart
  function-identifier:
    - match: '([_$]*[a-z][a-zA-Z0-9_$]*)(<(?:[a-zA-Z0-9_$<>?]|,\s*|\s+extends\s+)+>)?(\(|\s+=>)'
      captures:
        1: entity.name.function.dart
  keywords:
    - match: (?<!\$)\bas\b(?!\$)
      scope: keyword.cast.dart
    - match: (?<!\$)\b(try|on|catch|finally|throw|rethrow)\b(?!\$)
      scope: keyword.control.catch-exception.dart
    - match: (?<!\$)\b(break|case|continue|default|do|else|for|if|in|return|switch|while)\b(?!\$)
      scope: keyword.control.dart
    - match: (?<!\$)\b(sync(\*)?|async(\*)?|await|yield(\*)?)\b(?!\$)
      scope: keyword.control.dart
    - match: (?<!\$)\bassert\b(?!\$)
      scope: keyword.control.dart
    - match: (?<!\$)\b(new)\b(?!\$)
      scope: keyword.control.new.dart
    - match: (?<!\$)\b(abstract|class|enum|extends|extension|external|factory|implements|get|mixin|native|operator|set|typedef|with|covariant)\b(?!\$)
      scope: keyword.declaration.dart
    - match: (?<!\$)\b(is\!?)\b(?!\$)
      scope: keyword.operator.dart
    - match: '\?|:'
      scope: keyword.operator.ternary.dart
    - match: (<<|>>>?|~|\^|\||&)
      scope: keyword.operator.bitwise.dart
    - match: ((&|\^|\||<<|>>>?)=)
      scope: keyword.operator.assignment.bitwise.dart
    - match: (=>)
      scope: keyword.operator.closure.dart
    - match: (==|!=|<=?|>=?)
      scope: keyword.operator.comparison.dart
    - match: '(([+*/%-]|\~)=)'
      scope: keyword.operator.assignment.arithmetic.dart
    - match: (=)
      scope: keyword.operator.assignment.dart
    - match: (\-\-|\+\+)
      scope: keyword.operator.increment-decrement.dart
    - match: (\-|\+|\*|\/|\~\/|%)
      scope: keyword.operator.arithmetic.dart
    - match: (!|&&|\|\|)
      scope: keyword.operator.logical.dart
    - match: (?<!\$)\b(static|final|const|required|late)\b(?!\$)
      scope: storage.modifier.dart
    - match: (?<!\$)\b(?:void|var)\b(?!\$)
      scope: storage.type.primitive.dart
  punctuation:
    - match: ','
      scope: punctuation.comma.dart
    - match: ;
      scope: punctuation.terminator.dart
    - match: \.
      scope: punctuation.dot.dart
  string-interp:
    - match: '\$([a-zA-Z0-9_]+)'
      captures:
        1: variable.parameter.dart
    - match: '\$\{'
      push:
        - meta_scope: string.interpolated.expression.dart
        - match: '\}'
          pop: true
        - include: constants-and-special-vars
        - include: strings
        - match: '[a-zA-Z0-9_]+'
          scope: variable.parameter.dart
    - match: \\.
      scope: constant.character.escape.dart
  strings:
    - match: (?<!r)"""
      push:
        - meta_scope: string.interpolated.triple.double.dart
        - match: '"""(?!")'
          pop: true
        - include: string-interp
    - match: (?<!r)'''
      push:
        - meta_scope: string.interpolated.triple.single.dart
        - match: '''''''(?!'')'
          pop: true
        - include: string-interp
    - match: r"""
      push:
        - meta_scope: string.quoted.triple.double.dart
        - match: '"""(?!")'
          pop: true
    - match: r'''
      push:
        - meta_scope: string.quoted.triple.single.dart
        - match: '''''''(?!'')'
          pop: true
    - match: (?<!\|r)"
      push:
        - meta_scope: string.interpolated.double.dart
        - match: '"'
          pop: true
        - match: \n
          scope: invalid.string.newline
        - include: string-interp
    - match: r"
      push:
        - meta_scope: string.quoted.double.dart
        - match: '"'
          pop: true
        - match: \n
          scope: invalid.string.newline
    - match: (?<!\|r)'
      push:
        - meta_scope: string.interpolated.single.dart
        - match: "'"
          pop: true
        - match: \n
          scope: invalid.string.newline
        - include: string-interp
    - match: r'
      push:
        - meta_scope: string.quoted.single.dart
        - match: "'"
          pop: true
        - match: \n
          scope: invalid.string.newline
  type-args:
    - match: (<)
      captures:
        1: other.source.dart
      push:
        - match: (>)
          captures:
            1: other.source.dart
          pop: true
        - include: class-identifier
        - match: '[\s,]+'
        - match: extends
          scope: keyword.declaration.dart

@tsavo-at-pieces
Copy link

Here is a sharable link for the snippet with some other notes and related links that I found useful in this process!

https://tsavo.pieces.cloud/?p=960b448e34

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment