From f26faacb953df10899a8a28a127a4ebcbe6b79e1 Mon Sep 17 00:00:00 2001 From: chbk Date: Fri, 21 Feb 2025 13:28:22 +0100 Subject: [PATCH] Improve CSS syntax highlighting --- crates/languages/src/css/highlights.scm | 40 +++++++++++++++++-------- 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/crates/languages/src/css/highlights.scm b/crates/languages/src/css/highlights.scm index 4ddfe9a418ca70..7c13e90ec05577 100644 --- a/crates/languages/src/css/highlights.scm +++ b/crates/languages/src/css/highlights.scm @@ -11,6 +11,7 @@ ">" "+" "-" + "|" "*" "/" "=" @@ -19,35 +20,48 @@ "~=" "$=" "*=" +] @operator + +[ "and" "or" "not" "only" -] @operator +] @keyword.operator (attribute_selector (plain_value) @string) +[ + (id_name) + (class_name) +] @selector + +(namespace_name) @namespace +(namespace_selector (tag_name) @namespace "|") + (attribute_name) @attribute -(pseudo_element_selector (tag_name) @attribute) -(pseudo_class_selector (class_name) @attribute) +(pseudo_element_selector "::" (tag_name) @attribute) +(pseudo_class_selector ":" (class_name) @attribute) [ - (class_name) - (id_name) - (namespace_name) (feature_name) + (property_name) ] @property -(property_name) @constant - (function_name) @function +[ + (plain_value) + (keyframes_name) + (keyword_query) +] @constant + ( [ (property_name) (plain_value) - ] @variable.special - (#match? @variable.special "^--") + ] @variable + (#match? @variable "^--") ) [ @@ -61,7 +75,7 @@ (to) (from) (important) -] @keyword +] @keyword (string_value) @string (color_value) @string.special @@ -71,7 +85,7 @@ (float_value) ] @number -(unit) @type +(unit) @constant.unit [ "," @@ -79,7 +93,7 @@ "." "::" ";" - "#" + (id_selector "#") ] @punctuation.delimiter [