Skip to content

Commit 03663b9

Browse files
authored
rust: Highlight enum variants as variant (zed-industries#47918)
Improve zed-industries#45546, by changing the capture to be variant instead of type. Release Notes: - Improved Rust enum variant highlighting as variant instead of type. Before (note variants have the same style as `Foo`): <img width="276" height="162" alt="image" src="https://github.com/user-attachments/assets/fa0d8f48-a286-4a8d-b89d-269cb1657e55" /> After: <img width="276" height="162" alt="image" src="https://github.com/user-attachments/assets/c442494a-7550-481a-a8b9-f2d944a67868" />
1 parent 4dde88c commit 03663b9

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

crates/languages/src/rust.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1807,13 +1807,15 @@ mod tests {
18071807
("keyword", Hsla::default()),
18081808
("function", Hsla::default()),
18091809
("property", Hsla::default()),
1810+
("variant", Hsla::default()),
18101811
]);
18111812

18121813
language.set_theme(&theme);
18131814

18141815
let highlight_function = grammar.highlight_id_for_name("function").unwrap();
18151816
let highlight_type = grammar.highlight_id_for_name("type").unwrap();
18161817
let highlight_keyword = grammar.highlight_id_for_name("keyword").unwrap();
1818+
let highlight_variant = grammar.highlight_id_for_name("variant").unwrap();
18171819

18181820
assert_eq!(
18191821
adapter
@@ -1855,7 +1857,7 @@ mod tests {
18551857
Some(CodeLabel::new(
18561858
"Variant".to_string(),
18571859
0..7,
1858-
vec![(0..7, highlight_type)],
1860+
vec![(0..7, highlight_variant)],
18591861
))
18601862
);
18611863
}

crates/languages/src/rust/highlights.scm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
(#match? @constant "^_*[A-Z][A-Z\\d_]*$"))
5959

6060
; Ensure enum variants are highlighted correctly regardless of naming convention
61-
(enum_variant name: (identifier) @type)
61+
(enum_variant name: (identifier) @variant)
6262

6363
[
6464
"("

0 commit comments

Comments
 (0)