Skip to content

grammars: Distinguish control-flow keyword highlighting in Go - #63769

Open
Gami13 wants to merge 1 commit into
zed-industries:mainfrom
Gami13:go-control-keywords
Open

grammars: Distinguish control-flow keyword highlighting in Go#63769
Gami13 wants to merge 1 commit into
zed-industries:mainfrom
Gami13:go-control-keywords

Conversation

@Gami13

@Gami13 Gami13 commented Sep 4, 2026

Copy link
Copy Markdown

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:

  • I've reviewed my own diff for quality, security, and reliability
  • Unsafe blocks (if any) have justifying comments
  • The content adheres to Zed's UI standards (UX/UI and icon guidelines)
  • Tests cover the new/changed behavior
  • 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

Copilot AI lite review requested due to automatic review settings September 4, 2026 15:15
@cla-bot

cla-bot Bot commented Sep 4, 2026

Copy link
Copy Markdown

We require contributors to sign our Contributor License Agreement, and we don't have @Gami13 on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'.

@maxdeviant maxdeviant changed the title go: Distinguish control-flow keyword highlighting grammars: Distinguish control-flow keyword highlighting in Go Sep 4, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The change is small, localized to a highlight query file, and follows an existing capture convention already used by other grammars in the repository.

Pull request overview

Improves Go Tree-sitter highlighting by separating control-flow keywords from other language keywords, enabling themes (and optional Semantic Tokens) to style them differently and more consistently with other languages.

Changes:

  • Split Go reserved words into two highlight capture groups: @keyword and @keyword.control.
  • Reclassified control-flow-related keywords (e.g. if, for, return, switch) under @keyword.control while keeping non-control keywords (e.g. func, type, var) under @keyword.
File summaries
File Description
crates/grammars/src/go/highlights.scm Splits Go keyword captures into @keyword vs @keyword.control for improved syntax highlighting fidelity.
Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@Gami13

Gami13 commented Sep 4, 2026

Copy link
Copy Markdown
Author

@cla-bot check

@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label Sep 4, 2026
@cla-bot

cla-bot Bot commented Sep 4, 2026

Copy link
Copy Markdown

The cla-bot has been summoned, and re-checked this pull request!

@zed-community-bot zed-community-bot Bot added the first contribution the author's first pull request to Zed. NOTE: the label application is automated via github actions label Sep 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement first contribution the author's first pull request to Zed. NOTE: the label application is automated via github actions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants