From 113c471bb0aef8ecdb5f748359134c31545f0bb4 Mon Sep 17 00:00:00 2001 From: Finn Evers Date: Tue, 25 Feb 2025 01:10:30 +0100 Subject: [PATCH] rust: Restore and update attribute highlighting (#25501) #25333 added broader highlighting for identifiers, which broke the generic query for attribute queries, resulting in these being highlighted the same as identifiers. To accomodate for this change, this PR updates the attribute matches to be more specific. Additionally, path matches in scoped identifiers are no longer highlighted as attributes, as seen in the comparison screenshot. Can revert this if requested. | Zed Preview | preview | | --- | --- | | `main` | main | | This PR | pr | The generic match for `token_tree` is needed to recursively match patterns like `#[cfg(any(test, feature = "test-support"))]` (or at least I was unable to find a better query here). I tried to validate that this does not break any other highlights and I believe it does not. However, I might have still missed something. Release Notes: - N/A --- crates/languages/src/rust/highlights.scm | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/crates/languages/src/rust/highlights.scm b/crates/languages/src/rust/highlights.scm index 36e94ad2508e228f431bff7b2b08f0bccb30f52f..f52b8f1f9019b8a457c7097fd34041ac08b45327 100644 --- a/crates/languages/src/rust/highlights.scm +++ b/crates/languages/src/rust/highlights.scm @@ -190,5 +190,9 @@ operator: "/" @operator (parameter (identifier) @variable.parameter) -(attribute_item) @attribute -(inner_attribute_item) @attribute +(attribute_item (attribute (identifier) @attribute)) +(inner_attribute_item (attribute (identifier) @attribute)) +; 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 identifiers. +(token_tree (identifier) @variable "::")