From a3517499be4e83bf6e9cb2352bb6a30afa3c513b Mon Sep 17 00:00:00 2001 From: Gami Date: Sun, 6 Sep 2026 23:48:10 +0000 Subject: [PATCH] grammars: Distinguish control-flow keyword highlighting in Go (#63769) # Objective - Improve Go's syntax highlighting by distinguishing control-flow keywords from other keywords, in the same way it was done for other languages. ## Solution - Split keywords in `highlights.scm` into two groups: `keyword.control` and `keyword`. This change affects tree-sitter highlighting, enabling `Semantic Tokens` can override it. ## Testing - Tested locally on Windows using a development build, with `Semantic Tokens` disabled. Opened a Go file with a theme that assigns different colors to `keyword` and `keyword.control` ## Self-Review Checklist: - [x] I've reviewed my own diff for quality, security, and reliability - [x] Unsafe blocks (if any) have justifying comments - [x] The content adheres to Zed's UI standards ([UX/UI](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist) and [icon](https://github.com/zed-industries/zed/blob/main/crates/icons/README.md) guidelines) - [ ] Tests cover the new/changed behavior - [x] Performance impact has been considered and is acceptable ## Showcase - Screenshot showing a build without this change and one with it side by side after Release Notes: - Improved Go syntax highlighting by separating control-flow keywords from regular keywords --------- Co-authored-by: Finn Evers --- crates/grammars/src/go/highlights.scm | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/crates/grammars/src/go/highlights.scm b/crates/grammars/src/go/highlights.scm index aaec47bf5e..25ec7cb18d 100644 --- a/crates/grammars/src/go/highlights.scm +++ b/crates/grammars/src/go/highlights.scm @@ -101,32 +101,35 @@ ] @operator [ - "break" - "case" "chan" "const" + "func" + "import" + "interface" + "map" + "package" + "struct" + "type" + "var" +] @keyword + +[ + "break" + "case" "continue" "default" "defer" "else" "fallthrough" "for" - "func" "go" "goto" "if" - "import" - "interface" - "map" - "package" "range" "return" "select" - "struct" "switch" - "type" - "var" -] @keyword +] @keyword.control [ (interpreted_string_literal)