Skip to content

Commit b1df688

Browse files
authored
fix: rewrite all query files for correctness, compliance, and sassdoc highlighting (#35)
1 parent 77f8e21 commit b1df688

7 files changed

Lines changed: 185 additions & 82 deletions

File tree

languages/sassdoc/highlights.scm

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
; Base: paint entire document as doc comment so /// markers and all
2+
; uncaptured regions get a consistent doc comment color.
3+
; More specific patterns below will override for semantic elements.
4+
(document) @comment.doc
5+
16
; Tag keywords
27
[
38
"@param"
@@ -35,7 +40,7 @@
3540

3641
; Access modifiers
3742
(tag_access
38-
["public" "private"] @keyword.modifier)
43+
["public" "private"] @keyword)
3944

4045
; Reference types
4146
(reference) @type
@@ -50,36 +55,36 @@
5055
(version) @number
5156

5257
; Description text
53-
(description) @comment
54-
(line_description) @comment
58+
(description) @comment.doc
59+
(line_description) @comment.doc
5560

5661
; Example language identifier
5762
(example_language) @label
5863

59-
; Code blocks and lines - use @comment as fallback, injection will override with language-specific highlights
60-
(code_block) @comment
61-
(code_line) @comment
64+
; Code blocks and lines - use @comment.doc as fallback, injection will override with language-specific highlights
65+
(code_block) @comment.doc
66+
(code_line) @comment.doc
6267

6368
; See references
6469
(see_reference) @function
6570

6671
; Group names
67-
(group_name) @module
72+
(group_name) @type
6873

6974
; Alias names
7075
(alias_name) @function
7176

7277
; Package names
73-
(package_name) @module
78+
(package_name) @type
7479

7580
; Property names
7681
(property_name) @property
7782

7883
; URLs
79-
(url) @string.special.url
84+
(url) @string.special
8085

8186
; Link captions
82-
(link_caption) @comment
87+
(link_caption) @comment.doc
8388

8489
; Custom names
8590
(custom_name) @string

languages/scss/brackets.scm

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
("(" @open ")" @close)
22
("[" @open "]" @close)
33
("{" @open "}" @close)
4+
5+
; Interpolation brackets
6+
(interpolation
7+
"#{" @open
8+
"}" @close)

languages/scss/folds.scm

Lines changed: 53 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,62 @@
1-
; Fold blocks with braces
2-
(block) @fold
3-
4-
; Fold rule sets
1+
; Rule sets
52
(rule_set) @fold
63

7-
; Fold at-rule statements with blocks
8-
(media_statement) @fold
9-
(supports_statement) @fold
10-
(keyframes_statement) @fold
11-
(container_statement) @fold
12-
(layer_statement) @fold
13-
(scope_statement) @fold
14-
(starting_style_statement) @fold
15-
(view_transition_statement) @fold
16-
(font_face_statement) @fold
17-
(counter_style_statement) @fold
18-
(position_try_statement) @fold
19-
(font_palette_values_statement) @fold
20-
(page_statement) @fold
21-
(font_feature_values_statement) @fold
22-
23-
; Fold control flow statements
24-
(if_statement) @fold
25-
(each_statement) @fold
26-
(for_statement) @fold
27-
(while_statement) @fold
28-
29-
; Fold function and mixin definitions
30-
(function_statement) @fold
31-
(mixin_statement) @fold
32-
33-
; Fold placeholders
4+
; At-rule statements with blocks
5+
[
6+
(media_statement)
7+
(supports_statement)
8+
(keyframes_statement)
9+
(container_statement)
10+
(layer_statement)
11+
(scope_statement)
12+
(starting_style_statement)
13+
(view_transition_statement)
14+
(font_face_statement)
15+
(counter_style_statement)
16+
(position_try_statement)
17+
(font_palette_values_statement)
18+
(page_statement)
19+
(font_feature_values_statement)
20+
(property_statement)
21+
(at_root_statement)
22+
(at_rule)
23+
] @fold
24+
25+
; Nested at-rule blocks
26+
(margin_at_rule) @fold
27+
(font_feature_value_block) @fold
28+
(keyframe_block) @fold
29+
30+
; Control flow statements
31+
[
32+
(if_statement)
33+
(each_statement)
34+
(for_statement)
35+
(while_statement)
36+
] @fold
37+
38+
; Function and mixin definitions
39+
[
40+
(function_statement)
41+
(mixin_statement)
42+
] @fold
43+
44+
; Include statements with content blocks
45+
(include_statement) @fold
46+
47+
; Placeholders
3448
(placeholder) @fold
3549

36-
; Fold multi-line comments
50+
; Multi-line comments
3751
(comment) @fold
3852

39-
; Fold sassdoc blocks
53+
; Sassdoc blocks
4054
(sassdoc_block) @fold
4155

42-
; Fold map values (useful for large config maps)
56+
; Map values (useful for large config maps)
4357
(map_value) @fold
58+
59+
; Consecutive import/use/forward statements
60+
(import_statement)+ @fold
61+
(use_statement)+ @fold
62+
(forward_statement)+ @fold

languages/scss/highlights.scm

Lines changed: 48 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
[
22
(comment)
33
(single_line_comment)
4-
(sassdoc_block)
54
] @comment
65

6+
(sassdoc_block) @comment.doc
7+
8+
(tag_name) @tag
9+
710
[
8-
(tag_name)
911
(universal_selector)
1012
(nesting_selector)
11-
] @tag
13+
] @character.special
1214

1315
(attribute_selector (plain_value) @string)
1416
(parenthesized_query
@@ -60,16 +62,16 @@
6062
(unary_expression "not" @keyword.operator)
6163
]
6264

63-
(pseudo_element_selector "::" (tag_name) @selector.pseudo)
64-
(pseudo_class_selector ":" (class_name) @selector.pseudo)
65-
(page_pseudo_class) @selector.pseudo
65+
(pseudo_element_selector "::" (tag_name) @attribute)
66+
(pseudo_class_selector ":" (class_name) @attribute)
67+
(page_pseudo_class) @attribute
6668

6769
[
6870
(variable_name)
6971
(variable_value)
70-
] @variable.other.member
72+
] @variable
7173

72-
(container_statement (container_name) @variable.other.member)
74+
(container_statement (container_name) @variable)
7375

7476
(argument_name) @variable.parameter
7577

@@ -79,15 +81,15 @@
7981
(property_name)
8082
] @property
8183

82-
(id_name) @selector.id
83-
(class_name) @selector.class
84-
(placeholder_name) @selector.class
85-
(namespace_name) @namespace
86-
(namespace_selector (tag_name) @namespace "|")
87-
(variable_module (module) @namespace)
88-
(call_expression module: (module) @namespace)
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)
8991

90-
(attribute_name) @attribute
92+
(attribute_name) @tag.attribute
9193

9294
[
9395
(function_name)
@@ -99,11 +101,12 @@
99101

100102
[
101103
(plain_value)
102-
(keyframes_name)
103104
(keyword_query)
104105
(feature_value)
105106
] @constant.builtin
106107

108+
(keyframes_name) @variable
109+
107110
(interpolation "#{" @punctuation.special "}" @punctuation.special)
108111

109112
[
@@ -128,17 +131,22 @@
128131
"@debug"
129132
"@error"
130133
"@extend"
131-
"@mixin"
132134
"@warn"
133135
(at_keyword)
136+
(margin_at_keyword)
137+
(font_feature_value_keyword)
138+
] @keyword.directive
139+
140+
[
134141
(to)
135142
(from)
143+
] @keyword
144+
145+
[
136146
(important)
137147
(default)
138148
(global)
139-
(margin_at_keyword)
140-
(font_feature_value_keyword)
141-
] @keyword
149+
] @keyword.modifier
142150

143151
; Scope bare keyword strings to their parent nodes to avoid
144152
; false matches inside identifiers (e.g. "as" in "ease-out").
@@ -175,7 +183,7 @@
175183

176184
(attr_type (keyword) @keyword)
177185
(syntax_type) @type
178-
(if_else_condition) @keyword.control.conditional
186+
(if_else_condition) @keyword.conditional
179187

180188
(style_condition
181189
(property_name) @property)
@@ -184,15 +192,18 @@
184192
(state_name) @property
185193
(state_value) @constant.builtin)
186194

187-
"@function" @keyword.function
195+
[
196+
"@function"
197+
"@mixin"
198+
] @keyword.function
188199

189-
"@return" @keyword.control.return
200+
"@return" @keyword.return
190201

191202
[
192203
"@else"
193204
"@if"
194-
] @keyword.control.conditional
195-
(else_if_clause "if" @keyword.control.conditional)
205+
] @keyword.conditional
206+
(else_if_clause "if" @keyword.conditional)
196207

197208
; Scope loop keywords to their parent nodes
198209
[
@@ -209,16 +220,21 @@
209220
"@import"
210221
"@include"
211222
"@use"
212-
] @keyword.control.import
223+
] @keyword.import
224+
225+
; Custom properties (CSS variables) as @variable
226+
((property_name) @variable
227+
(#lua-match? @variable "^[-][-]"))
228+
229+
((plain_value) @variable
230+
(#lua-match? @variable "^[-][-]"))
213231

214232
(string_value) @string
215233
(color_value) @string.special
216234

217-
[
218-
(integer_value)
219-
(float_value)
220-
] @number
221-
(unit) @type.unit
235+
(integer_value) @number
236+
(float_value) @number.float
237+
(unit) @type
222238

223239
(boolean_value) @boolean
224240
(null_value) @constant.builtin

languages/scss/indents.scm

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,26 @@
1+
; CSS base indentation
2+
[
3+
(block)
4+
(declaration)
5+
] @indent.begin
6+
7+
(block
8+
"}" @indent.branch)
9+
10+
"}" @indent.dedent
11+
12+
(comment) @indent.ignore
13+
14+
; SCSS-specific indentation
115
[
216
(mixin_statement)
3-
(while_statement)
17+
(function_statement)
18+
(if_clause)
19+
(else_if_clause)
20+
(else_clause)
421
(each_statement)
22+
(for_statement)
23+
(while_statement)
24+
(include_statement)
25+
(placeholder)
526
] @indent.begin
6-
7-
(_ "{" "}" @end) @indent

languages/scss/injections.scm

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1+
; Inject comment parser for TODO/FIXME/NOTE highlighting
2+
((comment) @injection.content
3+
(#set! injection.language "comment"))
4+
5+
((single_line_comment) @injection.content
6+
(#set! injection.language "comment"))
7+
18
; Inject sassdoc into documentation blocks
2-
; sassdoc_block groups consecutive /// comments
39
((sassdoc_block) @injection.content
410
(#set! injection.language "sassdoc"))

0 commit comments

Comments
 (0)