Skip to content

Commit 1b205da

Browse files
MrSubidubiFrGoIs
authored andcommitted
rust: Improve highlighting within macros (zed-industries#37049)
This makes sure we do not apply the highlights for snake case identifiers as well as paths for attributes too broadly to all types of macros, which should make macros much more readable overall whilst keeping the highlighting for the attribute items. | Before | After | | --- | --- | | <img width="1414" height="958" alt="Bildschirmfoto 2025-08-28 um 00 37 58" src="https://github.com/user-attachments/assets/1254b9a2-d07a-4be4-9b4f-555a7c640302" /> | <img width="1414" height="958" alt="Bildschirmfoto 2025-08-28 um 00 37 38" src="https://github.com/user-attachments/assets/5f6dd66c-5469-4f27-9f1d-0a6e6e8d8085" /> | Release Notes: - rust: Improved highlighting within macros.
1 parent 9dc3580 commit 1b205da

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

crates/languages/src/rust/highlights.scm

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,12 +195,13 @@ operator: "/" @operator
195195
(attribute_item (attribute [
196196
(identifier) @attribute
197197
(scoped_identifier name: (identifier) @attribute)
198+
(token_tree (identifier) @attribute (#match? @attribute "^[a-z\\d_]*$"))
199+
(token_tree (identifier) @variable "::" (identifier) @type (#match? @type "^[A-Z]"))
198200
]))
201+
199202
(inner_attribute_item (attribute [
200203
(identifier) @attribute
201204
(scoped_identifier name: (identifier) @attribute)
205+
(token_tree (identifier) @attribute (#match? @attribute "^[a-z\\d_]*$"))
206+
(token_tree (identifier) @variable "::" (identifier) @type (#match? @type "^[A-Z]"))
202207
]))
203-
; Match nested snake case identifiers in attribute items.
204-
(token_tree (identifier) @attribute (#match? @attribute "^[a-z\\d_]*$"))
205-
; Override the attribute match for paths in scoped type/enum identifiers.
206-
(token_tree (identifier) @variable "::" (identifier) @type (#match? @type "^[A-Z]"))

0 commit comments

Comments
 (0)