Skip to content

Commit feaca7d

Browse files
committed
fix: highlighting issue and keep aligned with css one
1 parent fd2a54c commit feaca7d

4 files changed

Lines changed: 77 additions & 89 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "zed_scss"
3-
version = "0.1.6"
3+
version = "0.1.7"
44
edition = "2021"
55
license = "MIT"
66

extension.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
id = "scss"
22
name = "SCSS"
33
description = "SCSS and SASS support"
4-
version = "0.1.6"
4+
version = "0.1.7"
55
schema_version = 1
66
authors = ["Raunak Raj <bajrangcoders@gmail.com>"]
77
repository = "https://github.com/bajrangCoder/zed-scss"

languages/scss/highlights.scm

Lines changed: 74 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,11 @@
55

66
(sassdoc_block) @comment.doc
77

8-
(tag_name) @tag
9-
108
[
9+
(tag_name)
1110
(universal_selector)
1211
(nesting_selector)
13-
] @character.special
12+
] @tag
1413

1514
(attribute_selector (plain_value) @string)
1615
(parenthesized_query
@@ -40,38 +39,35 @@
4039
] @operator
4140

4241
; Scope keyword operators to their parent nodes to avoid
43-
; false matches inside identifiers (e.g. "not" in "annotation").
44-
; The capture must be placed on the string node itself (inside the
45-
; parentheses) to avoid highlighting the entire parent expression.
46-
[
47-
(binary_query "and" @keyword.operator)
48-
(binary_query "or" @keyword.operator)
49-
(unary_query "not" @keyword.operator)
50-
(unary_query "only" @keyword.operator)
51-
(style_query "and" @keyword.operator)
52-
(style_query "or" @keyword.operator)
53-
(style_query "not" @keyword.operator)
54-
(scroll_state_query "and" @keyword.operator)
55-
(scroll_state_query "or" @keyword.operator)
56-
(scroll_state_query "not" @keyword.operator)
57-
(if_style_condition "and" @keyword.operator)
58-
(if_style_condition "or" @keyword.operator)
59-
(if_style_condition "not" @keyword.operator)
60-
(binary_expression "and" @keyword.operator)
61-
(binary_expression "or" @keyword.operator)
62-
(unary_expression "not" @keyword.operator)
63-
]
64-
65-
(pseudo_element_selector "::" (tag_name) @attribute)
66-
(pseudo_class_selector ":" (class_name) @attribute)
67-
(page_pseudo_class) @attribute
42+
; false matches inside identifiers (e.g. "not" in "annotation")
43+
[
44+
(binary_query "and")
45+
(binary_query "or")
46+
(unary_query "not")
47+
(unary_query "only")
48+
(style_query "and")
49+
(style_query "or")
50+
(style_query "not")
51+
(scroll_state_query "and")
52+
(scroll_state_query "or")
53+
(scroll_state_query "not")
54+
(if_style_condition "and")
55+
(if_style_condition "or")
56+
(if_style_condition "not")
57+
(binary_expression "and")
58+
(binary_expression "or")
59+
(unary_expression "not")
60+
] @keyword.operator
61+
62+
(pseudo_element_selector "::" (tag_name) @selector.pseudo)
63+
(pseudo_class_selector ":" (class_name) @selector.pseudo)
64+
(page_pseudo_class) @selector.pseudo
6865

6966
[
7067
(variable_name)
7168
(variable_value)
72-
] @variable
73-
74-
(container_statement (container_name) @variable)
69+
(container_statement (container_name))
70+
] @variable.other.member
7571

7672
(argument_name) @variable.parameter
7773

@@ -81,15 +77,14 @@
8177
(property_name)
8278
] @property
8379

84-
(id_name) @constant
85-
(class_name) @type
86-
(placeholder_name) @type
87-
(namespace_name) @module
88-
(namespace_selector (tag_name) @module "|")
89-
(variable_module (module) @module)
90-
(call_expression module: (module) @module)
80+
(id_name) @selector.id
81+
(class_name) @selector.class
82+
(placeholder_name) @selector.class
83+
(namespace_name) @namespace
84+
(namespace_selector (tag_name) @namespace "|")
85+
(variable_module (module) @namespace)
9186

92-
(attribute_name) @tag.attribute
87+
(attribute_name) @attribute
9388

9489
[
9590
(function_name)
@@ -101,12 +96,11 @@
10196

10297
[
10398
(plain_value)
99+
(keyframes_name)
104100
(keyword_query)
105101
(feature_value)
106102
] @constant.builtin
107103

108-
(keyframes_name) @variable
109-
110104
(interpolation "#{" @punctuation.special "}" @punctuation.special)
111105

112106
[
@@ -133,57 +127,49 @@
133127
"@extend"
134128
"@warn"
135129
(at_keyword)
136-
(margin_at_keyword)
137-
(font_feature_value_keyword)
138-
] @keyword.directive
139-
140-
[
141130
(to)
142131
(from)
143-
] @keyword
144-
145-
[
146132
(important)
147133
(default)
148134
(global)
149-
] @keyword.modifier
135+
(margin_at_keyword)
136+
(font_feature_value_keyword)
137+
] @keyword
150138

151139
; Scope bare keyword strings to their parent nodes to avoid
152-
; false matches inside identifiers (e.g. "as" in "ease-out").
153-
; The capture must be placed on the string node itself (inside the
154-
; parentheses) to avoid highlighting the entire parent clause.
140+
; false matches inside identifiers (e.g. "as" in "ease-out")
155141
[
156-
(as_clause "as" @keyword)
157-
(with_clause "with" @keyword)
158-
(visibility_clause "hide" @keyword)
159-
(visibility_clause "show" @keyword)
160-
]
142+
(as_clause "as")
143+
(with_clause "with")
144+
(visibility_clause "hide")
145+
(visibility_clause "show")
146+
] @keyword
161147

162148
[
163-
(selector_query "selector" @function.builtin)
164-
(style_query "style" @function.builtin)
165-
(scroll_state_query "scroll-state" @function.builtin)
166-
(font_tech_query "font-tech" @function.builtin)
167-
(font_format_query "font-format" @function.builtin)
168-
(at_rule_query "at-rule" @function.builtin)
169-
(named_feature_query "named-feature" @function.builtin)
170-
(import_layer "layer" @function.builtin)
171-
(import_supports "supports" @function.builtin)
172-
(if_style_condition "style" @function.builtin)
173-
(if_media_condition "media" @function.builtin)
174-
(if_supports_condition "supports" @function.builtin)
175-
(if_sass_condition "sass" @function.builtin)
176-
]
149+
(selector_query "selector")
150+
(style_query "style")
151+
(scroll_state_query "scroll-state")
152+
(font_tech_query "font-tech")
153+
(font_format_query "font-format")
154+
(at_rule_query "at-rule")
155+
(named_feature_query "named-feature")
156+
(import_layer "layer")
157+
(import_supports "supports")
158+
(if_style_condition "style")
159+
(if_media_condition "media")
160+
(if_supports_condition "supports")
161+
(if_sass_condition "sass")
162+
] @function.builtin
177163

178164
[
179-
(if_expression (function_name) @function.builtin)
180-
(attr_expression (function_name) @function.builtin)
181-
(attr_type_function (function_name) @function.builtin)
182-
]
165+
(if_expression (function_name))
166+
(attr_expression (function_name))
167+
(attr_type_function (function_name))
168+
] @function.builtin
183169

184170
(attr_type (keyword) @keyword)
185171
(syntax_type) @type
186-
(if_else_condition) @keyword.conditional
172+
(if_else_condition) @keyword.control.conditional
187173

188174
(style_condition
189175
(property_name) @property)
@@ -197,13 +183,13 @@
197183
"@mixin"
198184
] @keyword.function
199185

200-
"@return" @keyword.return
186+
"@return" @keyword.control.return
201187

202188
[
203189
"@else"
204190
"@if"
205-
] @keyword.conditional
206-
(else_if_clause "if" @keyword.conditional)
191+
] @keyword.control.conditional
192+
(else_if_clause "if" @keyword.control.conditional)
207193

208194
; Scope loop keywords to their parent nodes
209195
[
@@ -220,21 +206,23 @@
220206
"@import"
221207
"@include"
222208
"@use"
223-
] @keyword.import
209+
] @keyword.control.import
224210

225211
; Custom properties (CSS variables) as @variable
226212
((property_name) @variable
227-
(#lua-match? @variable "^[-][-]"))
213+
(#match? @variable "^[-][-]"))
228214

229215
((plain_value) @variable
230-
(#lua-match? @variable "^[-][-]"))
216+
(#match? @variable "^[-][-]"))
231217

232218
(string_value) @string
233219
(color_value) @string.special
234220

235-
(integer_value) @number
236-
(float_value) @number.float
237-
(unit) @type
221+
[
222+
(integer_value)
223+
(float_value)
224+
] @number
225+
(unit) @type.unit
238226

239227
(boolean_value) @boolean
240228
(null_value) @constant.builtin

0 commit comments

Comments
 (0)