|
| 1 | +%YAML 1.2 |
| 2 | +# Extends built-in YAML syntax with support for embedded c++ blocks. |
| 3 | +# The blocks can either be specified using a "lambda" key or "!lambda" tag. |
| 4 | +# See https://esphome.io/guides/yaml/ and https://esphome.io/automations/templates/#config-lambda |
| 5 | +# for more details. |
| 6 | +# |
| 7 | +# Notes: |
| 8 | +# - Single and double-quoted "lambda" keys are not supported. |
| 9 | +--- |
| 10 | +# http://www.sublimetext.com/docs/syntax.html |
| 11 | +name: YAML (esphome) |
| 12 | +scope: source.yaml.esphome |
| 13 | +version: 2 |
| 14 | + |
| 15 | +extends: Packages/YAML/YAML.sublime-syntax |
| 16 | + |
| 17 | +contexts: |
| 18 | + block-pair: |
| 19 | + - meta_prepend: true |
| 20 | + - match: (lambda)\s*(:)(?=\s+|$) |
| 21 | + captures: |
| 22 | + 1: meta.mapping.key.yaml meta.string.yaml string.unquoted.plain.out.yaml |
| 23 | + 2: meta.mapping.yaml punctuation.separator.key-value.mapping.yaml |
| 24 | + push: lambda-body |
| 25 | + |
| 26 | + property-body: |
| 27 | + - meta_prepend: true |
| 28 | + - match: (?=!lambda\b) |
| 29 | + set: lambda-body |
| 30 | + |
| 31 | + lambda-body: |
| 32 | + - meta_include_prototype: false |
| 33 | + - match: \!lambda\b |
| 34 | + scope: meta.property.yaml keyword.control.directive.tag.yaml |
| 35 | + - match: (?:(\|)|(>))(?:([1-9])([-+])|([-+])?([1-9])?) # c-b-block-header(m,t) |
| 36 | + captures: |
| 37 | + 1: keyword.control.flow.block-scalar.literal.yaml |
| 38 | + 2: keyword.control.flow.block-scalar.folded.yaml |
| 39 | + 3: constant.numeric.indentation-indicator.yaml |
| 40 | + 4: storage.modifier.chomping-indicator.yaml |
| 41 | + 5: storage.modifier.chomping-indicator.yaml |
| 42 | + 6: constant.numeric.indentation-indicator.yaml |
| 43 | + set: lambda-block-scalar-body |
| 44 | + - match: \" |
| 45 | + scope: meta.string.yaml string.quoted.double.yaml punctuation.definition.string.begin.yaml |
| 46 | + pop: 1 |
| 47 | + embed: scope:source.c++#statements |
| 48 | + embed_scope: meta.string.yaml source.c++.embedded.yaml |
| 49 | + escape: \" |
| 50 | + escape_captures: |
| 51 | + 0: meta.string.yaml string.quoted.double.yaml punctuation.definition.string.end.yaml |
| 52 | + - match: \' |
| 53 | + scope: meta.string.yaml string.quoted.single.yaml punctuation.definition.string.begin.yaml |
| 54 | + pop: 1 |
| 55 | + embed: scope:source.c++#statements |
| 56 | + embed_scope: meta.string.yaml source.c++.embedded.yaml |
| 57 | + escape: \' |
| 58 | + escape_captures: |
| 59 | + 0: meta.string.yaml string.quoted.single.yaml punctuation.definition.string.end.yaml |
| 60 | + - match: (?=\S) |
| 61 | + pop: 1 |
| 62 | + embed: scope:source.c++#statements |
| 63 | + embed_scope: meta.string.yaml source.c++.embedded.yaml |
| 64 | + escape: $ |
| 65 | + - match: $ |
| 66 | + pop: 1 |
| 67 | + |
| 68 | + lambda-block-scalar-body: |
| 69 | + - meta_include_prototype: false |
| 70 | + - match: ^([ ]+)(?! ) |
| 71 | + pop: 1 |
| 72 | + embed: scope:source.c++#statements |
| 73 | + embed_scope: meta.string.yaml source.c++.embedded.yaml |
| 74 | + escape: ^(?!\1|\s*$) |
| 75 | + - match: ^(?=\S) # the block is empty |
| 76 | + pop: 1 |
| 77 | + - match: .+ |
| 78 | + scope: invalid.illegal.expected-comment-or-newline.yaml |
0 commit comments