## Summary Arguments of `preproc_call` nodes, like the `pack(push, 4)` in `#pragma pack(push, 4)` or the `FOO` in `#undef FOO`, had no highlight capture, so they always rendered as plain text. `#define` bodies are covered by the injection, and `#if` conditions are parsed as expressions, but nothing reached `preproc_call`'s `preproc_arg`. I added a `(preproc_call argument: (preproc_arg) @preproc)` rule to both the C and C++ highlight queries. I went with `@preproc` because every built-in theme already defines it, and it makes the whole directive line one color, like VS Code does. Happy to switch to `@constant.macro` or `@string` if you'd prefer. | Before | After | | --- | --- | | <img alt="preproc-before" src="https://github.com/user-attachments/assets/95fa0660-c41f-4433-98c7-887d9871fe1d" /> | <img alt="preproc-after" src="https://github.com/user-attachments/assets/7c4fa978-a6c1-4707-a627-6d7e32dd897a" /> | | <img alt="preproc-before-light" src="https://github.com/user-attachments/assets/3d2479ce-cd04-42ae-bfeb-e5c8c49fb9a6" /> | <img alt="preproc-after-light" src="https://github.com/user-attachments/assets/8d342f73-25e2-4dae-b984-72b88fd23287" /> | `#define FOO 1` and `#if defined(BAR)` look the same before and after. Closes #66675 ## Testing - Added a query test for C and one for C++, checking that `#pragma` and `#undef` arguments are captured as `preproc` and that a `#define` body isn't. Both fail without the query change. - `cargo test -p languages` passes (105 tests), and `./script/clippy -p languages` is clean. - Built the branch on macOS and compared it with Zed 1.28.1 on the same file, in One Dark and One Light (screenshots above). To try it: open a `.c` or `.cpp` file and type `#pragma pack(push, 4)` / `#undef FOO`. The arguments should now take the directive's color. I used Claude Code to help with this change and tested it myself. ## Self-review - [x] I've reviewed my diff for quality, security, reliability, and performance. - [x] UI changes follow the [checklist](https://zed.dev/docs/development/ui-checklist). - [x] Tests cover the new or changed behavior. Release Notes: - Improved syntax highlighting of `#pragma` and `#undef` arguments in C and C++. --------- Co-authored-by: imryanthedev <352313849+imryanthedev@users.noreply.github.com>
Zed
Welcome to Zed, a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Installation
On macOS, Linux, and Windows you can download Zed directly or install Zed via your local package manager (macOS/Linux/Windows).
Other platforms are not yet available:
- Web (tracking discussion)
Developing Zed
Contributing
See CONTRIBUTING.md for ways you can contribute to Zed.
Also... we're hiring! Check out our jobs page for open roles.
Licensing
Zed source code is licensed primarily under GPL-3.0-or-later, with Apache-2.0 components where marked.
License information for third party dependencies must be correctly provided for CI to pass.
We use cargo-about to automatically comply with open source licenses. If CI is failing, check the following:
- Is it showing a
no license specifiederror for a crate you've created? If so, addpublish = falseunder[package]in your crate's Cargo.toml. - Is the error
failed to satisfy license requirementsfor a dependency? If so, first determine what license the project has and whether this system is sufficient to comply with this license's requirements. If you're unsure, ask a lawyer. Once you've verified that this system is acceptable add the license's SPDX identifier to theacceptedarray inscript/licenses/zed-licenses.toml. - Is
cargo-aboutunable to find the license for a dependency? If so, add a clarification field at the end ofscript/licenses/zed-licenses.toml, as specified in the cargo-about book.
Sponsorship
Zed is developed by Zed Industries, Inc., a for-profit company.
If you’d like to financially support the project, you can do so via GitHub Sponsors. Sponsorships go directly to Zed Industries and are used as general company revenue. There are no perks or entitlements associated with sponsorship.