Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Improve CSS syntax highlighting (#25326)

chbk9e5f89dc26ed
diff --git a/assets/themes/ayu/ayu.json b/assets/themes/ayu/ayu.json
index de659dbe295..f9f87207290 100644
--- a/assets/themes/ayu/ayu.json
+++ b/assets/themes/ayu/ayu.json
@@ -261,6 +261,11 @@
"font_style": null,
"font_weight": null
},
+ "namespace": {
+ "color": "#bfbdb6ff",
+ "font_style": null,
+ "font_weight": null
+ },
"number": {
"color": "#d2a6ffff",
"font_style": null,
@@ -316,6 +321,16 @@
"font_style": null,
"font_weight": null
},
+ "selector": {
+ "color": "#d2a6ffff",
+ "font_style": null,
+ "font_weight": null
+ },
+ "selector.pseudo": {
+ "color": "#5ac1feff",
+ "font_style": null,
+ "font_weight": null
+ },
"string": {
"color": "#a9d94bff",
"font_style": null,
@@ -632,6 +647,11 @@
"font_style": null,
"font_weight": null
},
+ "namespace": {
+ "color": "#5c6166ff",
+ "font_style": null,
+ "font_weight": null
+ },
"number": {
"color": "#a37accff",
"font_style": null,
@@ -687,6 +707,16 @@
"font_style": null,
"font_weight": null
},
+ "selector": {
+ "color": "#a37accff",
+ "font_style": null,
+ "font_weight": null
+ },
+ "selector.pseudo": {
+ "color": "#3b9ee5ff",
+ "font_style": null,
+ "font_weight": null
+ },
"string": {
"color": "#86b300ff",
"font_style": null,
@@ -1003,6 +1033,11 @@
"font_style": null,
"font_weight": null
},
+ "namespace": {
+ "color": "#cccac2ff",
+ "font_style": null,
+ "font_weight": null
+ },
"number": {
"color": "#dfbfffff",
"font_style": null,
@@ -1058,6 +1093,16 @@
"font_style": null,
"font_weight": null
},
+ "selector": {
+ "color": "#dfbfffff",
+ "font_style": null,
+ "font_weight": null
+ },
+ "selector.pseudo": {
+ "color": "#72cffeff",
+ "font_style": null,
+ "font_weight": null
+ },
"string": {
"color": "#d4fe7fff",
"font_style": null,
diff --git a/assets/themes/gruvbox/gruvbox.json b/assets/themes/gruvbox/gruvbox.json
index fbbec827935..459825c733d 100644
--- a/assets/themes/gruvbox/gruvbox.json
+++ b/assets/themes/gruvbox/gruvbox.json
@@ -270,6 +270,11 @@
"font_style": null,
"font_weight": null
},
+ "namespace": {
+ "color": "#83a598ff",
+ "font_style": null,
+ "font_weight": null
+ },
"number": {
"color": "#d3869bff",
"font_style": null,
@@ -325,6 +330,16 @@
"font_style": null,
"font_weight": null
},
+ "selector": {
+ "color": "#fabd2eff",
+ "font_style": null,
+ "font_weight": null
+ },
+ "selector.pseudo": {
+ "color": "#83a598ff",
+ "font_style": null,
+ "font_weight": null
+ },
"string": {
"color": "#b8bb25ff",
"font_style": null,
@@ -655,6 +670,11 @@
"font_style": null,
"font_weight": null
},
+ "namespace": {
+ "color": "#83a598ff",
+ "font_style": null,
+ "font_weight": null
+ },
"number": {
"color": "#d3869bff",
"font_style": null,
@@ -710,6 +730,16 @@
"font_style": null,
"font_weight": null
},
+ "selector": {
+ "color": "#fabd2eff",
+ "font_style": null,
+ "font_weight": null
+ },
+ "selector.pseudo": {
+ "color": "#83a598ff",
+ "font_style": null,
+ "font_weight": null
+ },
"string": {
"color": "#b8bb25ff",
"font_style": null,
@@ -1040,6 +1070,11 @@
"font_style": null,
"font_weight": null
},
+ "namespace": {
+ "color": "#83a598ff",
+ "font_style": null,
+ "font_weight": null
+ },
"number": {
"color": "#d3869bff",
"font_style": null,
@@ -1095,6 +1130,16 @@
"font_style": null,
"font_weight": null
},
+ "selector": {
+ "color": "#fabd2eff",
+ "font_style": null,
+ "font_weight": null
+ },
+ "selector.pseudo": {
+ "color": "#83a598ff",
+ "font_style": null,
+ "font_weight": null
+ },
"string": {
"color": "#b8bb25ff",
"font_style": null,
@@ -1425,6 +1470,11 @@
"font_style": null,
"font_weight": null
},
+ "namespace": {
+ "color": "#066578ff",
+ "font_style": null,
+ "font_weight": null
+ },
"number": {
"color": "#8f3e71ff",
"font_style": null,
@@ -1480,6 +1530,16 @@
"font_style": null,
"font_weight": null
},
+ "selector": {
+ "color": "#b57613ff",
+ "font_style": null,
+ "font_weight": null
+ },
+ "selector.pseudo": {
+ "color": "#0b6678ff",
+ "font_style": null,
+ "font_weight": null
+ },
"string": {
"color": "#79740eff",
"font_style": null,
@@ -1810,6 +1870,11 @@
"font_style": null,
"font_weight": null
},
+ "namespace": {
+ "color": "#066578ff",
+ "font_style": null,
+ "font_weight": null
+ },
"number": {
"color": "#8f3e71ff",
"font_style": null,
@@ -1865,6 +1930,16 @@
"font_style": null,
"font_weight": null
},
+ "selector": {
+ "color": "#b57613ff",
+ "font_style": null,
+ "font_weight": null
+ },
+ "selector.pseudo": {
+ "color": "#0b6678ff",
+ "font_style": null,
+ "font_weight": null
+ },
"string": {
"color": "#79740eff",
"font_style": null,
@@ -2195,6 +2270,11 @@
"font_style": null,
"font_weight": null
},
+ "namespace": {
+ "color": "#066578ff",
+ "font_style": null,
+ "font_weight": null
+ },
"number": {
"color": "#8f3e71ff",
"font_style": null,
@@ -2250,6 +2330,16 @@
"font_style": null,
"font_weight": null
},
+ "selector": {
+ "color": "#b57613ff",
+ "font_style": null,
+ "font_weight": null
+ },
+ "selector.pseudo": {
+ "color": "#0b6678ff",
+ "font_style": null,
+ "font_weight": null
+ },
"string": {
"color": "#79740eff",
"font_style": null,
diff --git a/assets/themes/one/one.json b/assets/themes/one/one.json
index b0455f208ad..0163c0958ee 100644
--- a/assets/themes/one/one.json
+++ b/assets/themes/one/one.json
@@ -264,6 +264,11 @@
"font_style": null,
"font_weight": null
},
+ "namespace": {
+ "color": "#dce0e5ff",
+ "font_style": null,
+ "font_weight": null
+ },
"number": {
"color": "#bf956aff",
"font_style": null,
@@ -319,6 +324,16 @@
"font_style": null,
"font_weight": null
},
+ "selector": {
+ "color": "#dfc184ff",
+ "font_style": null,
+ "font_weight": null
+ },
+ "selector.pseudo": {
+ "color": "#74ade8ff",
+ "font_style": null,
+ "font_weight": null
+ },
"string": {
"color": "#a1c181ff",
"font_style": null,
@@ -643,6 +658,11 @@
"font_style": null,
"font_weight": null
},
+ "namespace": {
+ "color": "#242529ff",
+ "font_style": null,
+ "font_weight": null
+ },
"number": {
"color": "#ad6e25ff",
"font_style": null,
@@ -698,6 +718,16 @@
"font_style": null,
"font_weight": null
},
+ "selector": {
+ "color": "#669f59ff",
+ "font_style": null,
+ "font_weight": null
+ },
+ "selector.pseudo": {
+ "color": "#5c78e2ff",
+ "font_style": null,
+ "font_weight": null
+ },
"string": {
"color": "#649f57ff",
"font_style": null,
diff --git a/crates/languages/src/css/highlights.scm b/crates/languages/src/css/highlights.scm
index 4ddfe9a418c..8fbb9f47d2b 100644
--- a/crates/languages/src/css/highlights.scm
+++ b/crates/languages/src/css/highlights.scm
@@ -11,6 +11,7 @@
">"
"+"
"-"
+ "|"
"*"
"/"
"="
@@ -19,35 +20,50 @@
"~="
"$="
"*="
+] @operator
+
+[
"and"
"or"
"not"
"only"
-] @operator
+] @keyword.operator
+
+(id_name) @selector.id
+(class_name) @selector.class
-(attribute_selector (plain_value) @string)
+(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) @selector.pseudo)
+(pseudo_class_selector ":" (class_name) @selector.pseudo)
[
- (class_name)
- (id_name)
- (namespace_name)
(feature_name)
+ (property_name)
] @property
-(property_name) @constant
-
(function_name) @function
+[
+ (plain_value)
+ (keyframes_name)
+ (keyword_query)
+] @constant.builtin
+
+(attribute_selector
+ (plain_value) @string)
+
+(parenthesized_query
+ (keyword_query) @property)
+
(
[
(property_name)
(plain_value)
- ] @variable.special
- (#match? @variable.special "^--")
+ ] @variable
+ (#match? @variable "^--")
)
[
@@ -61,7 +77,7 @@
(to)
(from)
(important)
-] @keyword
+] @keyword
(string_value) @string
(color_value) @string.special
@@ -71,7 +87,7 @@
(float_value)
] @number
-(unit) @type
+(unit) @type.unit
[
","
@@ -79,9 +95,10 @@
"."
"::"
";"
- "#"
] @punctuation.delimiter
+(id_selector "#" @punctuation.delimiter)
+
[
"{"
")"