Skip to content

languages: Change syntax highlighting for C/C++ preprocessor directives#48109

Merged
osiewicz merged 1 commit intozed-industries:mainfrom
ozacod:feat/preproc-highlighting-cpp
Feb 10, 2026
Merged

languages: Change syntax highlighting for C/C++ preprocessor directives#48109
osiewicz merged 1 commit intozed-industries:mainfrom
ozacod:feat/preproc-highlighting-cpp

Conversation

@ozacod
Copy link
Contributor

@ozacod ozacod commented Jan 31, 2026

This changes the highlight capture for preprocessor directives from @keyword.directive to @preproc in both C and C++.

PR #44043 changed C from @keyword to @keyword.directive for consistency with C++, but @keyword.directive is still semantically wrong. Preprocessor directives are not language keywords — they are instructions to a separate preprocessing phase that runs before compilation.

Using @preproc reflects this distinction and allows themes to style them independently from actual language keywords like const, struct,if, etc. This is consistent with how editors like CLion handle preprocessor directives.

Before:
before

After:
after

Release Notes:

  • C/C++: Syntax highlighting for preprocessor directives can now be tweaked with @preproc capture group.

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Jan 31, 2026
@osiewicz osiewicz merged commit 61e5755 into zed-industries:main Feb 10, 2026
30 checks passed
@osiewicz
Copy link
Member

Cheers

chenwuji2000-cyber added a commit to chenwuji2000-cyber/zed that referenced this pull request Feb 12, 2026
PR zed-industries#48109 changed the capture name for C/C++ preprocessor directives
from `@keyword.directive` to `@preproc`. While semantically reasonable,
this caused an unintended side effect: most built-in themes define
`preproc` with colors nearly indistinguishable from plain text, making
`#include`, `#define`, etc. appear unhighlighted.

This commit uses `@keyword.preproc` instead, which both preserves the
semantic distinction (preprocessor directives ≠ language keywords) and
leverages HighlightMap's partial matching to fall back to the `keyword`
style — restoring visible highlighting across all themes without any
theme changes.

Fixes zed-industries#49024

Release Notes:

- Fixed C/C++ preprocessor directives (`#include`, `#define`, etc.)
  appearing unhighlighted in most themes.

Co-Authored-By: Claude <noreply@anthropic.com>
chenwuji2000-cyber added a commit to chenwuji2000-cyber/zed that referenced this pull request Feb 12, 2026
PR zed-industries#48109 changed the capture name for C/C++ preprocessor directives
from `@keyword.directive` to `@preproc`. While semantically correct,
the builtin themes had `preproc` defined with colors nearly
indistinguishable from plain text, causing `#include`, `#define`, etc.
to appear unhighlighted.

Update the `preproc` color in all builtin themes to match their
respective `keyword` color, restoring visible highlighting for
preprocessor directives.

Fixes zed-industries#49024

Release Notes:

- Fixed C/C++ preprocessor directives (`#include`, `#define`, etc.)
  appearing unhighlighted in builtin themes.

Co-Authored-By: Claude <noreply@anthropic.com>
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants