283 lines
7.7 KiB
JSON
283 lines
7.7 KiB
JSON
{
|
|
"$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.schema.json",
|
|
"name": "Structured CSS (STCSS)",
|
|
"scopeName": "source.stcss",
|
|
"patterns": [
|
|
{ "include": "#comment" },
|
|
{ "include": "#javascript-block" },
|
|
{ "include": "#variable-definition" },
|
|
{ "include": "#mixin-declaration" },
|
|
{ "include": "#rule" },
|
|
{ "include": "#at-rule" },
|
|
{ "include": "#value" }
|
|
],
|
|
"repository": {
|
|
"comment": {
|
|
"patterns": [
|
|
{
|
|
"name": "comment.block.stcss",
|
|
"begin": "/\\*",
|
|
"end": "\\*/"
|
|
},
|
|
{
|
|
"name": "comment.line.double-slash.stcss",
|
|
"match": "//[^{]*$"
|
|
}
|
|
]
|
|
},
|
|
"javascript-block": {
|
|
"name": "meta.embedded.block.ts.stcss",
|
|
"begin": "^\\s*(javascript|typescript)!\\s*$",
|
|
"beginCaptures": { "1": { "name": "keyword.control.stcss" } },
|
|
"end": "^\\s*end\\s*$",
|
|
"endCaptures": { "0": { "name": "keyword.control.stcss" } },
|
|
"patterns": [{ "include": "source.ts" }]
|
|
},
|
|
"variable-definition": {
|
|
"match": "^\\s*(\\$[\\w-]+)\\s*:",
|
|
"captures": {
|
|
"1": { "name": "variable.definition.stcss" }
|
|
}
|
|
},
|
|
"mixin-declaration": {
|
|
"match": "^\\s*(\\$[\\w-]+)\\s*\\(|^\\s*(mixin)\\s+([\\w-]+)\\s*(\\([^()]*\\))?",
|
|
"captures": {
|
|
"1": { "name": "variable.definition.stcss" },
|
|
"2": { "name": "keyword.control.stcss" },
|
|
"3": { "name": "entity.name.function.stcss" },
|
|
"4": { "name": "meta.function.parameters.stcss" }
|
|
}
|
|
},
|
|
"rule": {
|
|
"name": "meta.rule.stcss",
|
|
"begin": "^([^\\n{}]*?)\\s*\\{",
|
|
"end": "\\}",
|
|
"beginCaptures": {
|
|
"1": {
|
|
"name": "meta.selector.stcss",
|
|
"patterns": [{ "include": "#selector-content" }]
|
|
}
|
|
},
|
|
"endCaptures": {
|
|
"0": { "name": "punctuation.definition.block.end.bracket.curly.stcss" }
|
|
},
|
|
"patterns": [
|
|
{ "include": "#comment" },
|
|
{ "include": "#javascript-block" },
|
|
{ "include": "#variable-definition" },
|
|
{ "include": "#mixin-declaration" },
|
|
{ "include": "#rule" },
|
|
{ "include": "#at-rule" },
|
|
{ "include": "#declaration" },
|
|
{ "include": "#value" }
|
|
]
|
|
},
|
|
"at-rule": {
|
|
"match": "(@)(each|for|include|responsive|media|supports|concentric|view-transition|predict|measure|property|import|keyframes|layer|container|font-face|charset|document|page|scope|starting-style)(\\b[^;{\\n]*)?",
|
|
"captures": {
|
|
"1": { "name": "punctuation.definition.at-rule.stcss" },
|
|
"2": {
|
|
"patterns": [
|
|
{
|
|
"match": "^(?:each|for|include|responsive|concentric|predict|measure|property)$",
|
|
"name": "keyword.other.at-rule.muddle"
|
|
},
|
|
{
|
|
"match": "^.+$",
|
|
"name": "keyword.control.at-rule.stcss"
|
|
}
|
|
]
|
|
},
|
|
"3": {
|
|
"patterns": [
|
|
{ "include": "#interpolation" },
|
|
{ "include": "#anchor" },
|
|
{ "include": "#value" }
|
|
]
|
|
}
|
|
}
|
|
},
|
|
"selector-content": {
|
|
"patterns": [
|
|
{ "include": "#interpolation" },
|
|
{ "include": "#anchor" },
|
|
{ "include": "#variable" },
|
|
{
|
|
"match": "(\\.)([A-Za-z_][\\w-]*)",
|
|
"captures": {
|
|
"1": { "name": "punctuation.definition.class.stcss" },
|
|
"2": { "name": "entity.other.attribute-name.class.stcss" }
|
|
}
|
|
},
|
|
{
|
|
"match": "(#)([A-Za-z_][\\w-]*)",
|
|
"captures": {
|
|
"1": { "name": "punctuation.definition.id.stcss" },
|
|
"2": { "name": "entity.other.attribute-name.id.stcss" }
|
|
}
|
|
},
|
|
{ "match": "(&)", "name": "keyword.operator.parent-reference.stcss" },
|
|
{ "match": "[>+~]", "name": "keyword.operator.combinator.stcss" },
|
|
{
|
|
"match": "[\\w-]+(?=\\s*(?:$|[.#:&,*]|[\\[{]|\\s|,))",
|
|
"name": "entity.name.tag.stcss"
|
|
},
|
|
{ "include": "#pseudoclass" },
|
|
{ "include": "#attribute-selector" }
|
|
]
|
|
},
|
|
"pseudoclass": {
|
|
"patterns": [
|
|
{
|
|
"match": ":with|:when",
|
|
"name": "keyword.other.relation-selector.stcss"
|
|
}
|
|
]
|
|
},
|
|
"attribute-selector": {
|
|
"name": "meta.attribute-selector.stcss",
|
|
"begin": "\\[",
|
|
"beginCaptures": {
|
|
"0": { "name": "punctuation.definition.attribute-selector.begin.stcss" }
|
|
},
|
|
"end": "\\]",
|
|
"endCaptures": {
|
|
"0": { "name": "punctuation.definition.attribute-selector.end.stcss" }
|
|
},
|
|
"patterns": [
|
|
{ "include": "#interpolation" },
|
|
{ "include": "#variable" },
|
|
{
|
|
"match": "([a-zA-Z-][\\w-]*)\\s*(?=(?:[~^|$]?=)|\\])",
|
|
"captures": {
|
|
"1": { "name": "entity.other.attribute-name.attribute.stcss" }
|
|
}
|
|
},
|
|
{ "match": "[~^|$]?=", "name": "keyword.operator.stcss" },
|
|
{ "include": "#string" },
|
|
{ "include": "#number" }
|
|
]
|
|
},
|
|
"declaration": {
|
|
"match": "^\\s*([-a-zA-Z][\\w-]*)\\s*:",
|
|
"captures": {
|
|
"1": { "name": "support.type.property-name.css" }
|
|
}
|
|
},
|
|
"anchor": {
|
|
"match": "@[A-Za-z_][\\w-]*(?:\\.computed\\.[\\w-]+)?(?::(?:active|clicked|focus|hover|open|closed|selected|loading|visible|hidden)\\b)?",
|
|
"name": "entity.other.relation-anchor.stcss"
|
|
},
|
|
"refer": {
|
|
"match": "\\$(?:refer(\\[[\\w-]+\\])?|relate)",
|
|
"captures": {
|
|
"1": { "name": "keyword.other.unit.reference-metric.stcss" }
|
|
},
|
|
"name": "support.function.refer.stcss"
|
|
},
|
|
"interpolation": {
|
|
"name": "meta.interpolation.stcss",
|
|
"begin": "#\\{",
|
|
"beginCaptures": {
|
|
"0": { "name": "punctuation.definition.interpolation.begin.stcss" }
|
|
},
|
|
"end": "\\}",
|
|
"endCaptures": {
|
|
"0": { "name": "punctuation.definition.interpolation.end.stcss" }
|
|
},
|
|
"patterns": [
|
|
{ "include": "#curly-nesting" },
|
|
{ "include": "#expression" }
|
|
]
|
|
},
|
|
"curly-nesting": {
|
|
"begin": "\\{",
|
|
"beginCaptures": {
|
|
"0": { "name": "punctuation.definition.brace.curly.stcss" }
|
|
},
|
|
"end": "\\}",
|
|
"endCaptures": {
|
|
"0": { "name": "punctuation.definition.brace.curly.stcss" }
|
|
},
|
|
"patterns": [
|
|
{ "include": "#curly-nesting" },
|
|
{ "include": "#expression" }
|
|
]
|
|
},
|
|
"d-string": {
|
|
"name": "string.quoted.stcss",
|
|
"begin": "(?<!\\w)([dD])([\"'])",
|
|
"beginCaptures": {
|
|
"1": { "name": "keyword.other.stcss" },
|
|
"2": { "name": "punctuation.definition.string.begin.stcss" }
|
|
},
|
|
"end": "(?<!\\\\)\\2",
|
|
"endCaptures": {
|
|
"0": { "name": "punctuation.definition.string.end.stcss" }
|
|
},
|
|
"patterns": [
|
|
{ "include": "#interpolation" },
|
|
{ "include": "#expression" }
|
|
]
|
|
},
|
|
"string": {
|
|
"name": "string.quoted.stcss",
|
|
"begin": "(['\"])",
|
|
"beginCaptures": {
|
|
"0": { "name": "punctuation.definition.string.begin.stcss" }
|
|
},
|
|
"end": "(?<!\\\\)\\1",
|
|
"endCaptures": {
|
|
"0": { "name": "punctuation.definition.string.end.stcss" }
|
|
}
|
|
},
|
|
"number": {
|
|
"match": "(-)?(?<!\\w)(\\d+\\.?\\d*)(rem|em|px|vh|vw|%|ms|s|vmin|vmax|fr|deg)?\\b",
|
|
"captures": {
|
|
"1": { "name": "keyword.operator.unary.stcss" },
|
|
"2": { "name": "constant.numeric.decimal.stcss" },
|
|
"3": { "name": "keyword.other.unit.stcss" }
|
|
}
|
|
},
|
|
"color": {
|
|
"match": "#([0-9a-fA-F]{3}|[0-9a-fA-F]{4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})(?![\\w-])",
|
|
"name": "constant.other.color.rgb-value.stcss"
|
|
},
|
|
"variable": {
|
|
"match": "\\$[\\w-]+",
|
|
"name": "variable.other.stcss"
|
|
},
|
|
"function-call": {
|
|
"captures": {
|
|
"1": { "name": "support.function.stcss" }
|
|
},
|
|
"match": "(?<![@$.\\w-])([a-zA-Z][\\w-]*)(?=\\()"
|
|
},
|
|
"operator": {
|
|
"match": "!important\\b|&&|\\|\\||<=?|>=?|[*/%+-]",
|
|
"name": "keyword.operator.stcss"
|
|
},
|
|
"expression": {
|
|
"patterns": [
|
|
{ "include": "#comment" },
|
|
{ "include": "#d-string" },
|
|
{ "include": "#string" },
|
|
{ "include": "#refer" },
|
|
{ "include": "#interpolation" },
|
|
{ "include": "#anchor" },
|
|
{ "include": "#number" },
|
|
{ "include": "#color" },
|
|
{ "include": "#variable" },
|
|
{
|
|
"match": "--[\\w-]+",
|
|
"name": "variable.other.css.custom-property.stcss"
|
|
},
|
|
{ "include": "#function-call" },
|
|
{ "include": "#operator" }
|
|
]
|
|
},
|
|
"value": {
|
|
"patterns": [{ "include": "#expression" }]
|
|
}
|
|
}
|
|
}
|