|
| 1 | +%YAML 1.2 |
| 2 | +--- |
| 3 | +# https://www.sublimetext.com/docs/syntax.html |
| 4 | +scope: source.css.sublime |
| 5 | +version: 2 |
| 6 | +hidden: true |
| 7 | + |
| 8 | +extends: Packages/CSS/CSS.sublime-syntax |
| 9 | + |
| 10 | +contexts: |
| 11 | + |
| 12 | + stylesheet: |
| 13 | + # Note: ST doesn't support at-rules |
| 14 | + - include: comments |
| 15 | + - include: selectors |
| 16 | + - include: property-lists |
| 17 | + - include: rule-terminators |
| 18 | + - include: illegal-commas |
| 19 | + - include: illegal-groups |
| 20 | + |
| 21 | + at-rules: [] |
| 22 | + nested-at-rules: [] |
| 23 | + |
| 24 | + property-list-body: |
| 25 | + # Note: ST doesn't support nested selectors |
| 26 | + - meta_include_prototype: false |
| 27 | + - meta_scope: meta.property-list.css meta.block.css |
| 28 | + - match: '{{block_end}}' |
| 29 | + scope: punctuation.section.block.end.css |
| 30 | + pop: 1 |
| 31 | + - include: comments |
| 32 | + - include: property-identifiers |
| 33 | + - include: property-values |
| 34 | + - include: rule-terminators |
| 35 | + - include: illegal-commas |
| 36 | + - include: illegal-blocks |
| 37 | + - include: illegal-groups |
| 38 | + |
| 39 | +###[ BUILTIN FUNCTIONS ]####################################################### |
| 40 | + |
| 41 | + builtin-functions: |
| 42 | + # Note: ST only supports a limited subset of CSS functions |
| 43 | + - include: color-adjuster-functions |
| 44 | + |
| 45 | +###[ COLOR FUNCTIONS ]######################################################### |
| 46 | + |
| 47 | + color-functions: |
| 48 | + - meta_prepend: true |
| 49 | + # proprietary color function supported by Sublime Text |
| 50 | + - match: \b((?i:min-contrast))(\() |
| 51 | + captures: |
| 52 | + 1: meta.function-call.identifier.css support.function.css |
| 53 | + 2: meta.function-call.arguments.css meta.group.css punctuation.section.group.begin.css |
| 54 | + push: color-function-argument-list-body |
| 55 | + |
| 56 | + color-function-argument-list-body: |
| 57 | + - meta_content_scope: meta.function-call.arguments.css meta.group.css |
| 58 | + - match: \) |
| 59 | + scope: meta.function-call.arguments.css meta.group.css punctuation.section.group.end.css |
| 60 | + pop: 1 |
| 61 | + - include: var-functions |
| 62 | + - include: color-adjuster-functions |
| 63 | + - include: color-values |
| 64 | + - include: none-constants |
| 65 | + - include: numeric-constants |
| 66 | + - include: sublime-color-variables |
| 67 | + - include: other-constants |
| 68 | + |
| 69 | + color-adjuster-functions: |
| 70 | + # color adjuster functions supported by Sublime Text |
| 71 | + - match: \b((?i:blenda?|alpha|saturation|lightness|[asl]))(\() |
| 72 | + captures: |
| 73 | + 1: meta.function-call.identifier.css support.function.css |
| 74 | + 2: meta.function-call.arguments.css meta.group.css punctuation.section.group.begin.css |
| 75 | + push: color-adjuster-function-argument-list-body |
| 76 | + |
| 77 | + color-adjuster-function-argument-list-body: |
| 78 | + - meta_content_scope: meta.function-call.arguments.css meta.group.css |
| 79 | + - match: \) |
| 80 | + scope: meta.function-call.arguments.css meta.group.css punctuation.section.group.end.css |
| 81 | + pop: 1 |
| 82 | + - include: var-functions |
| 83 | + - include: color-adjuster-operators |
| 84 | + - include: color-values |
| 85 | + - include: none-constants |
| 86 | + - include: numeric-constants |
| 87 | + - include: sublime-color-variables |
| 88 | + - match: \b(?i:rgb|hsl|hwb){{break}} |
| 89 | + scope: keyword.other.color-space.css |
| 90 | + - include: other-constants |
| 91 | + |
| 92 | + var-functions: |
| 93 | + - match: \b((?i:var))(\() |
| 94 | + captures: |
| 95 | + 1: meta.function-call.identifier.css support.function.css |
| 96 | + 2: meta.function-call.arguments.css meta.group.css punctuation.section.group.begin.css |
| 97 | + push: var-function-argument-list-body |
| 98 | + |
| 99 | + var-function: |
| 100 | + - match: \b((?i:var))(\() |
| 101 | + captures: |
| 102 | + 1: meta.function-call.identifier.css support.function.css |
| 103 | + 2: meta.function-call.arguments.css meta.group.css punctuation.section.group.begin.css |
| 104 | + push: var-function-argument-list-body |
| 105 | + |
| 106 | + var-function-argument-list-body: |
| 107 | + # ST's `var()` function does not support default values (e.g. `var(name #fff)`) |
| 108 | + - meta_content_scope: meta.function-call.arguments.css meta.group.css |
| 109 | + - match: \) |
| 110 | + scope: meta.function-call.arguments.css meta.group.css punctuation.section.group.end.css |
| 111 | + pop: 1 |
| 112 | + - include: sublime-color-variables |
| 113 | + - include: sublime-other-variables |
| 114 | + |
| 115 | +###[ IDENTIFIERS ]############################################################# |
| 116 | + |
| 117 | + none-constants: |
| 118 | + # Note: required until sublimehq/Packages/pulls/3717 (<ST4149) |
| 119 | + - match: (?i:none){{break}} |
| 120 | + scope: constant.language.null.css |
| 121 | + |
| 122 | + sublime-color-variables: |
| 123 | + - match: |- |
| 124 | + (?x) |
| 125 | + --(?: |
| 126 | + background |
| 127 | + | foreground |
| 128 | + | accent |
| 129 | + | bluish |
| 130 | + | cyanish |
| 131 | + | greenish |
| 132 | + | orangish |
| 133 | + | pinkish |
| 134 | + | purplish |
| 135 | + | redish |
| 136 | + | yellowish |
| 137 | + ){{break}} |
| 138 | + scope: variable.language.sublime-color-scheme |
| 139 | +
|
| 140 | + sublime-other-variables: |
| 141 | + # Supports identifiers with and without leading `--` |
| 142 | + - match: '{{ident}}' |
| 143 | + scope: variable.other.sublime-color-scheme |
| 144 | + |
| 145 | +###[ PUNCTUATION ]############################################################# |
| 146 | + |
| 147 | + illegal-commas: |
| 148 | + # Note: required until sublimehq/Packages/pulls/3831 (<ST4174) |
| 149 | + - match: ',' |
| 150 | + scope: invalid.illegal.unexpected-token.css |
| 151 | + |
| 152 | +############################################################################### |
| 153 | + |
| 154 | +variables: |
| 155 | + # Block punctuation |
| 156 | + # Note: required until sublimehq/Packages/pulls/4055 (<ST4193) |
| 157 | + block_end: \} |
0 commit comments