From 047402e9b63a763283c3e57f47fa1d2cd52f1baf Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Tue, 14 Nov 2023 18:53:20 +0100 Subject: [PATCH] [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 */