From 9a97f9465b08954ef3dc1729d3ad6abed0485620 Mon Sep 17 00:00:00 2001 From: Finn Evers Date: Thu, 28 Aug 2025 00:57:08 +0200 Subject: [PATCH] rust: Improve highlighting within macros (#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 | | --- | --- | | Bildschirmfoto 2025-08-28 um 00 37
58 | Bildschirmfoto 2025-08-28 um 00
37 38 | Release Notes: - rust: Improved highlighting within macros. --- crates/languages/src/rust/highlights.scm | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/crates/languages/src/rust/highlights.scm b/crates/languages/src/rust/highlights.scm index 1c46061827..3f44c5fc0e 100644 --- a/crates/languages/src/rust/highlights.scm +++ b/crates/languages/src/rust/highlights.scm @@ -195,12 +195,13 @@ operator: "/" @operator (attribute_item (attribute [ (identifier) @attribute (scoped_identifier name: (identifier) @attribute) + (token_tree (identifier) @attribute (#match? @attribute "^[a-z\\d_]*$")) + (token_tree (identifier) @variable "::" (identifier) @type (#match? @type "^[A-Z]")) ])) + (inner_attribute_item (attribute [ (identifier) @attribute (scoped_identifier name: (identifier) @attribute) + (token_tree (identifier) @attribute (#match? @attribute "^[a-z\\d_]*$")) + (token_tree (identifier) @variable "::" (identifier) @type (#match? @type "^[A-Z]")) ])) -; Match nested snake case identifiers in attribute items. -(token_tree (identifier) @attribute (#match? @attribute "^[a-z\\d_]*$")) -; Override the attribute match for paths in scoped type/enum identifiers. -(token_tree (identifier) @variable "::" (identifier) @type (#match? @type "^[A-Z]"))