zed-industries / zed

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
https://zed.dev
Other
42.58k stars 2.27k forks source link

Zig "orelse" keyword mistakenly highlighted as symbol #9355

Open TeamPuzel opened 4 months ago

TeamPuzel commented 4 months ago

Check for existing issues

Describe the bug / provide steps to reproduce it

image

In all themes the orelse keyword is not highlighted correctly, instead being treated as a symbol. Does not happen in vscode.

Environment

Zed: v0.126.2 (Zed) OS: macOS 14.4.0 Memory: 32 GiB Architecture: aarch64

If applicable, add mockups / screenshots to help explain present your vision of the feature

No response

If applicable, attach your ~/Library/Logs/Zed/Zed.log file to this issue.

No response

TeamPuzel commented 4 months ago

Noticed some additional weirdness

The error ! is highlighted like a keyword

image

Some builtin functions are colored like keywords, others are not

image image image
TeamPuzel commented 4 months ago
image

Found more, or and and keywords are also not highlighted properly

mrnugget commented 4 months ago

Hey @TeamPuzel! Zig highlights are defined here, via tree-sitter queries: https://github.com/zed-industries/zed/blob/main/crates/languages/src/zig/highlights.scm

To fix those (if you want to take a stab, or someone else):

  1. Get Zed running from source: cargo run /path/to/zig/project
  2. Open a Zig file
  3. Open the debug tree-sitter view: debug: open syntax tree view
  4. Move your cursor to syntax node that you think needs changed highlighting
  5. See what the node name is in the tree view
  6. Open crates/languages/src/zig/highlights.scm in another editor instance, edit the highlights in there, save and you should see changes
  7. Repeat (6) until you're happy with results.

Recommendation: look at highlights of other languages to see what the proper captures are (the things that start with @). Rust is probably our best-supported language.