From b76773533a5fa871611f230be416d97e19d698d3 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Sat, 21 Mar 2026 20:44:10 +0100 Subject: [PATCH 1/3] Add Sublime Text specific CSS --- .../Sublime CSS (for JSON).sublime-syntax | 15 ++ .../Sublime CSS/Sublime CSS.sublime-syntax | 157 +++++++++++ .../Sublime JSON/Sublime JSON.sublime-syntax | 11 +- .../Sublime Text Color Scheme.sublime-syntax | 255 ++++++------------ .../syntax_test_colorscheme.json | 124 +++++++-- .../Sublime Text Theme.sublime-syntax | 58 ++-- .../syntax_test_newstyletheme.json | 91 +++++-- 7 files changed, 461 insertions(+), 250 deletions(-) create mode 100644 Package/Sublime CSS/Sublime CSS (for JSON).sublime-syntax create mode 100644 Package/Sublime CSS/Sublime CSS.sublime-syntax diff --git a/Package/Sublime CSS/Sublime CSS (for JSON).sublime-syntax b/Package/Sublime CSS/Sublime CSS (for JSON).sublime-syntax new file mode 100644 index 00000000..7fcf7f57 --- /dev/null +++ b/Package/Sublime CSS/Sublime CSS (for JSON).sublime-syntax @@ -0,0 +1,15 @@ +%YAML 1.2 +--- +# https://www.sublimetext.com/docs/syntax.html +scope: source.css.sublime.json-string +version: 2 +hidden: true + +extends: Sublime CSS.sublime-syntax + +contexts: + prototype: + - meta_prepend: true + - include: Sublime JSON.sublime-syntax#string-escape + - match: $|(?=") + pop: 1 diff --git a/Package/Sublime CSS/Sublime CSS.sublime-syntax b/Package/Sublime CSS/Sublime CSS.sublime-syntax new file mode 100644 index 00000000..b1888b0c --- /dev/null +++ b/Package/Sublime CSS/Sublime CSS.sublime-syntax @@ -0,0 +1,157 @@ +%YAML 1.2 +--- +# https://www.sublimetext.com/docs/syntax.html +scope: source.css.sublime +version: 2 +hidden: true + +extends: Packages/CSS/CSS.sublime-syntax + +contexts: + + stylesheet: + # Note: ST doesn't support at-rules + - include: comments + - include: selectors + - include: property-lists + - include: rule-terminators + - include: illegal-commas + - include: illegal-groups + + at-rules: [] + nested-at-rules: [] + + property-list-body: + # Note: ST doesn't support nested selectors + - meta_include_prototype: false + - meta_scope: meta.property-list.css meta.block.css + - match: '{{block_end}}' + scope: punctuation.section.block.end.css + pop: 1 + - include: comments + - include: property-identifiers + - include: property-values + - include: rule-terminators + - include: illegal-commas + - include: illegal-blocks + - include: illegal-groups + +###[ BUILTIN FUNCTIONS ]####################################################### + + builtin-functions: + # Note: ST only supports a limited subset of CSS functions + - include: color-adjuster-functions + +###[ COLOR FUNCTIONS ]######################################################### + + color-functions: + - meta_prepend: true + # proprietary color function supported by Sublime Text + - match: \b((?i:min-contrast))(\() + captures: + 1: meta.function-call.identifier.css support.function.css + 2: meta.function-call.arguments.css meta.group.css punctuation.section.group.begin.css + push: color-function-argument-list-body + + color-function-argument-list-body: + - meta_content_scope: meta.function-call.arguments.css meta.group.css + - match: \) + scope: meta.function-call.arguments.css meta.group.css punctuation.section.group.end.css + pop: 1 + - include: var-functions + - include: color-adjuster-functions + - include: color-values + - include: none-constants + - include: numeric-constants + - include: sublime-color-variables + - include: other-constants + + color-adjuster-functions: + # color adjuster functions supported by Sublime Text + - match: \b((?i:blenda?|alpha|saturation|lightness|[asl]))(\() + captures: + 1: meta.function-call.identifier.css support.function.css + 2: meta.function-call.arguments.css meta.group.css punctuation.section.group.begin.css + push: color-adjuster-function-argument-list-body + + color-adjuster-function-argument-list-body: + - meta_content_scope: meta.function-call.arguments.css meta.group.css + - match: \) + scope: meta.function-call.arguments.css meta.group.css punctuation.section.group.end.css + pop: 1 + - include: var-functions + - include: color-adjuster-operators + - include: color-values + - include: none-constants + - include: numeric-constants + - include: sublime-color-variables + - match: \b(?i:rgb|hsl|hwb){{break}} + scope: keyword.other.color-space.css + - include: other-constants + + var-functions: + - match: \b((?i:var))(\() + captures: + 1: meta.function-call.identifier.css support.function.css + 2: meta.function-call.arguments.css meta.group.css punctuation.section.group.begin.css + push: var-function-argument-list-body + + var-function: + - match: \b((?i:var))(\() + captures: + 1: meta.function-call.identifier.css support.function.css + 2: meta.function-call.arguments.css meta.group.css punctuation.section.group.begin.css + push: var-function-argument-list-body + + var-function-argument-list-body: + # ST's `var()` function does not support default values (e.g. `var(name #fff)`) + - meta_content_scope: meta.function-call.arguments.css meta.group.css + - match: \) + scope: meta.function-call.arguments.css meta.group.css punctuation.section.group.end.css + pop: 1 + - include: sublime-color-variables + - include: sublime-other-variables + +###[ IDENTIFIERS ]############################################################# + + none-constants: + # Note: required until sublimehq/Packages/pulls/3717 ( Date: Mon, 23 Mar 2026 18:26:07 +0100 Subject: [PATCH 2/3] Restore var() meta scope Restore required meta scope to maintain color value completions. --- Package/Sublime CSS/Sublime CSS.sublime-syntax | 1 + .../syntax_test_colorscheme.json | 8 +++++--- Package/Sublime Text Theme/syntax_test_newstyletheme.json | 8 ++++---- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/Package/Sublime CSS/Sublime CSS.sublime-syntax b/Package/Sublime CSS/Sublime CSS.sublime-syntax index b1888b0c..f6c26c7e 100644 --- a/Package/Sublime CSS/Sublime CSS.sublime-syntax +++ b/Package/Sublime CSS/Sublime CSS.sublime-syntax @@ -105,6 +105,7 @@ contexts: var-function-argument-list-body: # ST's `var()` function does not support default values (e.g. `var(name #fff)`) + - meta_scope: meta.function-call.var.sublime-color-scheme - meta_content_scope: meta.function-call.arguments.css meta.group.css - match: \) scope: meta.function-call.arguments.css meta.group.css punctuation.section.group.end.css diff --git a/Package/Sublime Text Color Scheme/syntax_test_colorscheme.json b/Package/Sublime Text Color Scheme/syntax_test_colorscheme.json index 312a9722..28d4cbca 100644 --- a/Package/Sublime Text Color Scheme/syntax_test_colorscheme.json +++ b/Package/Sublime Text Color Scheme/syntax_test_colorscheme.json @@ -49,7 +49,7 @@ // ^^^^^^ entity.name.globals.sublime-color-scheme // ^ punctuation.separator.mapping.key-value.json // ^^^^^^^^^^^^^^^^^^^^^^^ meta.mapping.value.json meta.color.sublime-color-scheme -// ^^^^^^^^^^^^^^^^^^^^^ - string +// ^^^^^^^^^^^^^^^^^^^^^ meta.function-call.var.sublime-color-scheme - string // ^ string.quoted.double.json punctuation.definition.string.begin.json // ^^^ support.function.css // ^ punctuation.section.group.begin.css @@ -170,11 +170,13 @@ // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.css-color - string // ^^^^^ meta.function-call.identifier.css - meta.function-call meta.function-call // ^ meta.function-call.arguments.css meta.group.css - meta.function-call meta.function-call -// ^^^ meta.function-call.arguments.css meta.group.css meta.function-call.identifier.css - meta.function-call meta.function-call meta.function-call -// ^^^^^^^^^^^^ meta.function-call.arguments.css meta.group.css meta.function-call.arguments.css meta.group.css - meta.function-call meta.function-call meta.function-call +// ^^^^^^^^^^^^^^^ meta.function-call.var.sublime-color-scheme +// ^^^ meta.function-call.arguments.css meta.group.css meta.function-call.identifier.css - meta.function-call meta.function-call meta.function-call meta.function-call +// ^^^^^^^^^^^^ meta.function-call.arguments.css meta.group.css meta.function-call.arguments.css meta.group.css - meta.function-call meta.function-call meta.function-call meta.function-call // ^ meta.function-call.arguments.css meta.group.css - meta.function-call meta.function-call // ^^^^^^^^^^^^ meta.function-call.arguments.css meta.group.css meta.function-call.identifier.css - meta.function-call meta.function-call meta.function-call // ^ meta.function-call.arguments.css meta.group.css meta.function-call.arguments.css meta.group.css punctuation.section.group.begin.css - meta.function-call meta.function-call meta.function-call +// ^^^^^^^^^^^^^^^^^ meta.function-call.var.sublime-color-scheme // ^^^ meta.function-call.arguments.css meta.group.css meta.function-call.arguments.css meta.group.css meta.function-call.identifier.css support.function.css // ^^^^^^^^^^^^^^ meta.function-call.arguments.css meta.group.css meta.function-call.arguments.css meta.group.css meta.function-call.arguments.css meta.group.css // ^^^^^ meta.function-call.arguments.css meta.group.css meta.function-call.arguments.css meta.group.css - meta.function-call meta.function-call meta.function-call diff --git a/Package/Sublime Text Theme/syntax_test_newstyletheme.json b/Package/Sublime Text Theme/syntax_test_newstyletheme.json index 1eba85f6..59f712b5 100644 --- a/Package/Sublime Text Theme/syntax_test_newstyletheme.json +++ b/Package/Sublime Text Theme/syntax_test_newstyletheme.json @@ -124,7 +124,7 @@ // ^ punctuation.separator.mapping.key-value.json // ^^^^^^^^^^^^^^^^^^^ meta.mapping.value.json meta.color.sublime-color-scheme meta.string.json // ^ string.quoted.double.json punctuation.definition.string.begin.json -// ^^^^^^^^^^^^^^^^^ source.css-color +// ^^^^^^^^^^^^^^^^^ source.css-color meta.function-call.var.sublime-color-scheme // ^^^ meta.function-call.identifier.css support.function // ^^^^^^^^^^^^^^ meta.function-call.arguments.css meta.group.css // ^ punctuation.section.group.begin.css @@ -177,7 +177,7 @@ // ^ punctuation.separator.mapping.key-value.json // ^^^^^^^^^^^^^^^^^^^^^^^^ meta.mapping.value.json meta.color-adjuster.sublime-color-scheme meta.string.json // ^ string.quoted.double.json punctuation.definition.string.begin.json -// ^^^^^^^^^^^^^^^^^^^^^^ source.css-color-adjuster +// ^^^^^^^^^^^^^^^^^^^^^^ source.css-color-adjuster meta.function-call.var.sublime-color-scheme // ^^^ meta.function-call.identifier.css support.function.css // ^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.css meta.group.css // ^ punctuation.section.group.begin.css @@ -208,7 +208,7 @@ "opacity": "var(icon_button_opacity)", // ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.mapping.value.json meta.string.json // ^ string.quoted.double.json punctuation.definition.string.begin.json -// ^^^^^^^^^^^^^^^^^^^^^^^^ source.css-color +// ^^^^^^^^^^^^^^^^^^^^^^^^ source.css-color meta.function-call.var.sublime-color-scheme // ^^^ meta.function-call.identifier.css support.function.css // ^^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.css meta.group.css // ^ punctuation.section.group.begin.css @@ -223,7 +223,7 @@ "font.size": "var(default_size)" // ^^^^^^^^^^^^^^^^^^^ meta.mapping.value.json meta.string.json // ^ string.quoted.double.json punctuation.definition.string.begin.json -// ^^^^^^^^^^^^^^^^^ source.css-color +// ^^^^^^^^^^^^^^^^^ source.css-color meta.function-call.var.sublime-color-scheme // ^^^ meta.function-call.identifier.css support.function.css // ^^^^^^^^^^^^^^ meta.function-call.arguments.css meta.group.css // ^ punctuation.section.group.begin.css From d9b07205b2e39b8e8cc659581090465183515c3f Mon Sep 17 00:00:00 2001 From: deathaxe Date: Mon, 23 Mar 2026 18:37:33 +0100 Subject: [PATCH 3/3] Adjust completion selectors As `string` scope is removed from css values, this commit adds some adjustments. --- .../Completions/Globals Keys.sublime-completions | 2 +- .../Completions/Main Keys.sublime-completions | 2 +- .../Completions/Rule Keys.sublime-completions | 2 +- .../Completions/Attributes.sublime-completions | 2 +- .../Completions/Interpolation Keys.sublime-completions | 2 +- .../Completions/Main Keys.sublime-completions | 2 +- .../Completions/Parent Keys.sublime-completions | 2 +- .../Completions/Platform Values.sublime-completions | 2 +- .../Completions/Rule Keys.sublime-completions | 2 +- .../Completions/Texture Keys.sublime-completions | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Package/Sublime Text Color Scheme/Completions/Globals Keys.sublime-completions b/Package/Sublime Text Color Scheme/Completions/Globals Keys.sublime-completions index 23325e73..51cce419 100644 --- a/Package/Sublime Text Color Scheme/Completions/Globals Keys.sublime-completions +++ b/Package/Sublime Text Color Scheme/Completions/Globals Keys.sublime-completions @@ -1,5 +1,5 @@ { - "scope": "meta.globals.sublime-color-scheme - string - comment", + "scope": "meta.globals.sublime-color-scheme - meta.mapping.key - meta.string - string - comment", "completions": [ { "trigger": "accent", diff --git a/Package/Sublime Text Color Scheme/Completions/Main Keys.sublime-completions b/Package/Sublime Text Color Scheme/Completions/Main Keys.sublime-completions index 27244c47..827b65ec 100644 --- a/Package/Sublime Text Color Scheme/Completions/Main Keys.sublime-completions +++ b/Package/Sublime Text Color Scheme/Completions/Main Keys.sublime-completions @@ -1,5 +1,5 @@ { - "scope": "meta.color-scheme.collection.sublime-color-scheme - meta.mapping meta.mapping - meta.sequence - string - comment", + "scope": "meta.color-scheme.collection.sublime-color-scheme - meta.mapping meta.mapping - meta.sequence - meta.string - string - comment", "completions": [ { "trigger": "variables", diff --git a/Package/Sublime Text Color Scheme/Completions/Rule Keys.sublime-completions b/Package/Sublime Text Color Scheme/Completions/Rule Keys.sublime-completions index 956f9ffb..ff26cff7 100644 --- a/Package/Sublime Text Color Scheme/Completions/Rule Keys.sublime-completions +++ b/Package/Sublime Text Color Scheme/Completions/Rule Keys.sublime-completions @@ -1,5 +1,5 @@ { - "scope": "meta.rule.sublime-color-scheme - meta.sequence meta.sequence - string - comment", + "scope": "meta.rule.sublime-color-scheme - meta.sequence meta.sequence - meta.string - string - comment", "completions": [ { "trigger": "scope", diff --git a/Package/Sublime Text Theme/Completions/Attributes.sublime-completions b/Package/Sublime Text Theme/Completions/Attributes.sublime-completions index 05c1c7d8..aec3b3b4 100644 --- a/Package/Sublime Text Theme/Completions/Attributes.sublime-completions +++ b/Package/Sublime Text Theme/Completions/Attributes.sublime-completions @@ -1,5 +1,5 @@ { - "scope": "meta.attributes-sequence.sublime-theme - string - comment", + "scope": "meta.attributes-sequence.sublime-theme - meta.string - string - comment", "completions": [ { "trigger": "hover", diff --git a/Package/Sublime Text Theme/Completions/Interpolation Keys.sublime-completions b/Package/Sublime Text Theme/Completions/Interpolation Keys.sublime-completions index 60517430..faf723af 100644 --- a/Package/Sublime Text Theme/Completions/Interpolation Keys.sublime-completions +++ b/Package/Sublime Text Theme/Completions/Interpolation Keys.sublime-completions @@ -1,5 +1,5 @@ { - "scope": "meta.interpolation-mapping.sublime-theme - string - comment", + "scope": "meta.interpolation-mapping.sublime-theme - meta.string - string - comment", "completions": [ { "trigger": "target", diff --git a/Package/Sublime Text Theme/Completions/Main Keys.sublime-completions b/Package/Sublime Text Theme/Completions/Main Keys.sublime-completions index 92c9c6c5..33eac3fd 100644 --- a/Package/Sublime Text Theme/Completions/Main Keys.sublime-completions +++ b/Package/Sublime Text Theme/Completions/Main Keys.sublime-completions @@ -1,5 +1,5 @@ { - "scope": "meta.theme.sublime-theme - meta.mapping meta.mapping - meta.sequence - string - comment", + "scope": "meta.theme.sublime-theme - meta.mapping meta.mapping - meta.sequence - meta.string - string - comment", "completions": [ { "trigger": "extends", diff --git a/Package/Sublime Text Theme/Completions/Parent Keys.sublime-completions b/Package/Sublime Text Theme/Completions/Parent Keys.sublime-completions index 86ca43e3..c6b48f3c 100644 --- a/Package/Sublime Text Theme/Completions/Parent Keys.sublime-completions +++ b/Package/Sublime Text Theme/Completions/Parent Keys.sublime-completions @@ -1,5 +1,5 @@ { - "scope": "meta.parent-mapping.sublime-theme - meta.parent-mapping.sublime-theme meta meta - string - comment", + "scope": "meta.parent-mapping.sublime-theme - meta.parent-mapping.sublime-theme meta meta - meta.string - string - comment", "completions": [ // selectors { diff --git a/Package/Sublime Text Theme/Completions/Platform Values.sublime-completions b/Package/Sublime Text Theme/Completions/Platform Values.sublime-completions index 41bcb46a..6e811dd9 100644 --- a/Package/Sublime Text Theme/Completions/Platform Values.sublime-completions +++ b/Package/Sublime Text Theme/Completions/Platform Values.sublime-completions @@ -1,5 +1,5 @@ { - "scope": "meta.platforms-sequence.sublime-theme - string - comment", + "scope": "meta.platforms-sequence.sublime-theme - meta.string - string - comment", "completions": [ { "trigger": "linux", diff --git a/Package/Sublime Text Theme/Completions/Rule Keys.sublime-completions b/Package/Sublime Text Theme/Completions/Rule Keys.sublime-completions index 86467dee..17abbc33 100644 --- a/Package/Sublime Text Theme/Completions/Rule Keys.sublime-completions +++ b/Package/Sublime Text Theme/Completions/Rule Keys.sublime-completions @@ -1,5 +1,5 @@ { - "scope": "meta.rule.sublime-theme - meta.rule.sublime-theme meta meta - string - comment", + "scope": "meta.rule.sublime-theme - meta.rule.sublime-theme meta meta - meta.string - string - comment", "completions": [ // selectors { diff --git a/Package/Sublime Text Theme/Completions/Texture Keys.sublime-completions b/Package/Sublime Text Theme/Completions/Texture Keys.sublime-completions index 4c4f4088..16954d8d 100644 --- a/Package/Sublime Text Theme/Completions/Texture Keys.sublime-completions +++ b/Package/Sublime Text Theme/Completions/Texture Keys.sublime-completions @@ -1,5 +1,5 @@ { - "scope": "meta.texture-mapping.sublime-theme - meta.texture-mapping.sublime-theme meta.sequence - string - comment", + "scope": "meta.texture-mapping.sublime-theme - meta.texture-mapping.sublime-theme meta.sequence - meta.string - string - comment", "completions": [ { "trigger": "keyframes",