Highlight control flow in Rust/C/C++ (#39683)
Hayashi Mikihiro
created 2 weeks ago
part of https://github.com/zed-industries/zed/issues/9461
Release Notes:
- Added the ability to seperately highlight control flow keywords for
Rust, C and C++ for users and theme authors via the `keyword.control`
syntax property
<img width="805" height="475" alt="γΉγ―γͺγΌγ³γ·γ§γγ 2025-10-07 22 21 59"
src="https://github.com/user-attachments/assets/40ed03ea-a129-44ce-b6d8-284656b9f3ba"
/>
Change summary
crates/languages/src/c/highlights.scm | 25 +++++++++-------
crates/languages/src/cpp/highlights.scm | 39 ++++++++++++++------------
crates/languages/src/rust/highlights.scm | 25 +++++++++-------
3 files changed, 49 insertions(+), 40 deletions(-)
Detailed changes
@@ -1,27 +1,30 @@
+[
+ "const"
+ "enum"
+ "extern"
+ "inline"
+ "sizeof"
+ "static"
+ "struct"
+ "typedef"
+ "union"
+ "volatile"
+] @keyword
+
[
"break"
"case"
- "const"
"continue"
"default"
"do"
"else"
- "enum"
- "extern"
"for"
"goto"
"if"
- "inline"
"return"
- "sizeof"
- "static"
- "struct"
"switch"
- "typedef"
- "union"
- "volatile"
"while"
-] @keyword
+] @keyword.control
[
"#define"
@@ -106,32 +106,19 @@ type: (primitive_type) @type.builtin
[
"alignas"
"alignof"
- "break"
- "case"
- "catch"
"class"
- "co_await"
- "co_return"
- "co_yield"
"concept"
"consteval"
"constexpr"
"constinit"
- "continue"
"decltype"
- "default"
"delete"
- "do"
- "else"
"enum"
"explicit"
"export"
"extern"
"final"
- "for"
"friend"
- "goto"
- "if"
"import"
"inline"
"module"
@@ -144,24 +131,40 @@ type: (primitive_type) @type.builtin
"protected"
"public"
"requires"
- "return"
"sizeof"
"struct"
- "switch"
"template"
"thread_local"
- "throw"
- "try"
"typedef"
"typename"
"union"
"using"
"virtual"
- "while"
(storage_class_specifier)
(type_qualifier)
] @keyword
+[
+ "break"
+ "case"
+ "catch"
+ "co_await"
+ "co_return"
+ "co_yield"
+ "continue"
+ "default"
+ "do"
+ "else"
+ "for"
+ "goto"
+ "if"
+ "return"
+ "switch"
+ "throw"
+ "try"
+ "while"
+] @keyword.control
+
[
"#define"
"#elif"
@@ -83,29 +83,20 @@
"as"
"async"
"await"
- "break"
"const"
- "continue"
"default"
"dyn"
- "else"
"enum"
"extern"
"fn"
- "for"
- "if"
"impl"
- "in"
"let"
- "loop"
"macro_rules!"
- "match"
"mod"
"move"
"pub"
"raw"
"ref"
- "return"
"static"
"struct"
"trait"
@@ -114,13 +105,25 @@
"unsafe"
"use"
"where"
- "while"
- "yield"
(crate)
(mutable_specifier)
(super)
] @keyword
+[
+ "break"
+ "continue"
+ "else"
+ "for"
+ "if"
+ "in"
+ "loop"
+ "match"
+ "return"
+ "while"
+ "yield"
+] @keyword.control
+
[
(string_literal)
(raw_string_literal)