From 047402e9b63a763283c3e57f47fa1d2cd52f1baf Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Tue, 14 Nov 2023 18:53:20 +0100 Subject: [PATCH 1/4] [CSS] Add support for at-scope rule Resolves #3867 This commit implements support for @scope rules. see: https://developer.mozilla.org/en-US/docs/Web/CSS/@scope --- CSS/CSS.sublime-syntax | 28 ++++++++++++++++++++++++ CSS/syntax_test_css.css | 47 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+) diff --git a/CSS/CSS.sublime-syntax b/CSS/CSS.sublime-syntax index 3d2210e13e..4f554724b4 100644 --- a/CSS/CSS.sublime-syntax +++ b/CSS/CSS.sublime-syntax @@ -387,6 +387,7 @@ contexts: - include: at-page - include: at-page-margin - include: at-property + - include: at-scope - include: at-scroll-timeline - include: at-other @@ -406,6 +407,7 @@ contexts: - include: at-page - include: at-page-margin - include: at-property + - include: at-scope - include: at-scroll-timeline - include: at-other @@ -892,6 +894,32 @@ contexts: - include: comments - include: else-pop +###[ SCROPE AT-RULE ]########################################################## + + at-scope: + - match: (@)(?i:scope){{break}} + scope: keyword.control.directive.css + captures: + 1: punctuation.definition.keyword.css + push: at-scope-selector + + at-scope-selector: + - meta_scope: meta.at-rule.scope.css + - match: \( + scope: punctuation.section.group.begin.css + push: at-scope-selector-group-body + - match: to{{break}} + scope: keyword.other.css + - include: else-pop + + at-scope-selector-group-body: + - meta_scope: meta.group.css + - meta_content_scope: meta.selector.css + - match: \) + scope: punctuation.section.group.end.css + pop: 1 + - include: selector-body + ###[ SCROLL-TIMELINE AT-RULE ]################################################# # @scroll-timeline diff --git a/CSS/syntax_test_css.css b/CSS/syntax_test_css.css index af8ee09953..c8f32b9eb2 100644 --- a/CSS/syntax_test_css.css +++ b/CSS/syntax_test_css.css @@ -1554,6 +1554,53 @@ /* ^ punctuation.terminator.rule.css */ } + @scope +/* ^^^^^^ meta.at-rule.scope.css keyword.control.directive.css */ + + @scope to ; +/* ^^^^^^^^^^ meta.at-rule.scope.css */ +/* ^^^^^^ keyword.control.directive.css */ +/* ^^ keyword.other.css */ +/* ^ punctuation.terminator.rule.css */ + + @scope () to () {} +/* ^^^^^^^^^^^^^^^^ meta.at-rule.scope.css */ +/* ^^ meta.group.css */ +/* ^^ meta.group.css */ +/* ^^ meta.property-list.css meta.block.css */ +/* ^ punctuation.definition.keyword.css */ +/* ^^^^^^ keyword.control.directive.css */ +/* ^ punctuation.section.group.begin.css */ +/* ^ punctuation.section.group.end.css */ +/* ^^ keyword.other.css */ +/* ^ punctuation.section.group.begin.css */ +/* ^ punctuation.section.group.end.css */ +/* ^ punctuation.section.block.begin.css */ +/* ^ punctuation.section.block.end.css */ + + @scope (.class) to (.limit > *) {} +/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.at-rule.scope.css */ +/* ^ meta.group.css - meta.selector */ +/* ^^^^^^ meta.at-rule.scope.css meta.group.css meta.selector.css */ +/* ^ meta.group.css - meta.selector */ +/* ^ meta.group.css - meta.selector */ +/* ^^^^^^^^^^ meta.at-rule.scope.css meta.group.css meta.selector.css */ +/* ^ meta.group.css - meta.selector */ +/* ^^ meta.property-list.css meta.block.css */ +/* ^ punctuation.definition.keyword.css */ +/* ^^^^^^ keyword.control.directive.css */ +/* ^ punctuation.section.group.begin.css */ +/* ^^^^^^ entity.other.attribute-name.class.css */ +/* ^ punctuation.section.group.end.css */ +/* ^^ keyword.other.css */ +/* ^ punctuation.section.group.begin.css */ +/* ^^^^^^ entity.other.attribute-name.class.css */ +/* ^ keyword.operator.combinator.css */ +/* ^ constant.other.wildcard.asterisk.css */ +/* ^ punctuation.section.group.end.css */ +/* ^ punctuation.section.block.begin.css */ +/* ^ punctuation.section.block.end.css */ + @scroll-timeline /* ^^^^^^^^^^^^^^^^^ meta.at-rule.scroll-timeline.css */ /* ^ keyword.control.directive.css punctuation.definition.keyword.css */ From a4328f25f0c2165a44208b6a31acc0474015632c Mon Sep 17 00:00:00 2001 From: deathaxe Date: Fri, 17 Nov 2023 19:24:15 +0100 Subject: [PATCH 2/4] [CSS] Fix typo --- CSS/CSS.sublime-syntax | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CSS/CSS.sublime-syntax b/CSS/CSS.sublime-syntax index 4f554724b4..c7c69444d4 100644 --- a/CSS/CSS.sublime-syntax +++ b/CSS/CSS.sublime-syntax @@ -894,7 +894,7 @@ contexts: - include: comments - include: else-pop -###[ SCROPE AT-RULE ]########################################################## +###[ SCOPE AT-RULE ]########################################################### at-scope: - match: (@)(?i:scope){{break}} From 0a2bbbf3e45d5d5179400da4b3459e24c071ccdc Mon Sep 17 00:00:00 2001 From: deathaxe Date: Sat, 18 Nov 2023 13:08:23 +0100 Subject: [PATCH 3/4] [CSS] Add reference to MDN --- CSS/CSS.sublime-syntax | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CSS/CSS.sublime-syntax b/CSS/CSS.sublime-syntax index c7c69444d4..95b3ee3503 100644 --- a/CSS/CSS.sublime-syntax +++ b/CSS/CSS.sublime-syntax @@ -896,6 +896,8 @@ contexts: ###[ SCOPE AT-RULE ]########################################################### + # @scope + # https://developer.mozilla.org/en-US/docs/Web/CSS/@scope at-scope: - match: (@)(?i:scope){{break}} scope: keyword.control.directive.css From 01747d50c69fdb7882287d88c92e384738723349 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Sat, 3 Feb 2024 12:07:16 +0100 Subject: [PATCH 4/4] [CSS] Improve accuracy of @scope at-rule Strictly follow https://developer.mozilla.org/en-US/docs/Web/CSS/@scope#formal_syntax --- CSS/CSS.sublime-syntax | 26 ++++++++++++++++++++----- CSS/syntax_test_css.css | 42 +++++++++++++++++++++++++++++++++++++++-- 2 files changed, 61 insertions(+), 7 deletions(-) diff --git a/CSS/CSS.sublime-syntax b/CSS/CSS.sublime-syntax index 95b3ee3503..1978a182c1 100644 --- a/CSS/CSS.sublime-syntax +++ b/CSS/CSS.sublime-syntax @@ -903,15 +903,31 @@ contexts: scope: keyword.control.directive.css captures: 1: punctuation.definition.keyword.css - push: at-scope-selector + push: + - at-scope-selector-meta + - maybe-property-list + - at-scope-selector-to + - at-scope-selector-group - at-scope-selector: + at-scope-selector-meta: + - meta_include_prototype: false - meta_scope: meta.at-rule.scope.css - - match: \( - scope: punctuation.section.group.begin.css - push: at-scope-selector-group-body + - include: immediately-pop + + at-scope-selector-to: + - meta_include_prototype: false - match: to{{break}} scope: keyword.other.css + set: at-scope-selector-group + - include: comments + - include: else-pop + + at-scope-selector-group: + - meta_include_prototype: false + - match: \( + scope: punctuation.section.group.begin.css + set: at-scope-selector-group-body + - include: comments - include: else-pop at-scope-selector-group-body: diff --git a/CSS/syntax_test_css.css b/CSS/syntax_test_css.css index c8f32b9eb2..e98b23b5ef 100644 --- a/CSS/syntax_test_css.css +++ b/CSS/syntax_test_css.css @@ -1557,14 +1557,33 @@ @scope /* ^^^^^^ meta.at-rule.scope.css keyword.control.directive.css */ + @scope {} +/* ^^^^^^^^^ meta.at-rule.scope.css */ +/* ^^^^^^ keyword.control.directive.css */ +/* ^^ meta.property-list.css meta.block.css */ + @scope to ; /* ^^^^^^^^^^ meta.at-rule.scope.css */ /* ^^^^^^ keyword.control.directive.css */ /* ^^ keyword.other.css */ /* ^ punctuation.terminator.rule.css */ + @scope () {} +/* ^^^^^^^^^^^^ meta.at-rule.scope.css */ +/* ^^^^^^ keyword.control.directive.css */ +/* ^^ meta.group.css */ +/* ^^ meta.property-list.css meta.block.css */ + + @scope () () {} +/* ^^^^^^^^^^ meta.at-rule.scope.css */ +/* ^^^^^ - meta.at-rule */ +/* ^^^^^^ keyword.control.directive.css */ +/* ^^ meta.group.css */ +/* ^^ invalid.illegal.unexpected-token.css */ +/* ^^ meta.property-list.css meta.block.css */ + @scope () to () {} -/* ^^^^^^^^^^^^^^^^ meta.at-rule.scope.css */ +/* ^^^^^^^^^^^^^^^^^^ meta.at-rule.scope.css */ /* ^^ meta.group.css */ /* ^^ meta.group.css */ /* ^^ meta.property-list.css meta.block.css */ @@ -1578,8 +1597,27 @@ /* ^ punctuation.section.block.begin.css */ /* ^ punctuation.section.block.end.css */ + @scope /**/ () /**/ to /**/ () /**/ {} +/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.at-rule.scope.css */ +/* ^^ meta.group.css */ +/* ^^ meta.group.css */ +/* ^^ meta.property-list.css meta.block.css */ +/* ^ punctuation.definition.keyword.css */ +/* ^^^^^^ keyword.control.directive.css */ +/* ^^^^ comment.block.css */ +/* ^ punctuation.section.group.begin.css */ +/* ^ punctuation.section.group.end.css */ +/* ^^^^ comment.block.css */ +/* ^^ keyword.other.css */ +/* ^^^^ comment.block.css */ +/* ^ punctuation.section.group.begin.css */ +/* ^ punctuation.section.group.end.css */ +/* ^^^^ comment.block.css */ +/* ^ punctuation.section.block.begin.css */ +/* ^ punctuation.section.block.end.css */ + @scope (.class) to (.limit > *) {} -/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.at-rule.scope.css */ +/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.at-rule.scope.css */ /* ^ meta.group.css - meta.selector */ /* ^^^^^^ meta.at-rule.scope.css meta.group.css meta.selector.css */ /* ^ meta.group.css - meta.selector */