Skip to content

lsp: Add clangd readonly token modifier to semantic token rules to highlight constant variables as constant#49065

Merged
Veykril merged 1 commit intozed-industries:mainfrom
ozacod:feat/clangd-readonly
Mar 16, 2026
Merged

lsp: Add clangd readonly token modifier to semantic token rules to highlight constant variables as constant#49065
Veykril merged 1 commit intozed-industries:mainfrom
ozacod:feat/clangd-readonly

Conversation

@ozacod
Copy link
Copy Markdown
Contributor

@ozacod ozacod commented Feb 12, 2026

Clangd uses the "readonly" token modifier instead of "constant". Therefore, "readonly" should be mapped to highlight constant variables as constants.

Before:
before

After:
after

  • Code Reviewed
  • Manual QA

Release Notes:

  • Added clangd readonly token modifier to semantic token rules to highlight constant variables as constant.
@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label Feb 12, 2026
@maxdeviant maxdeviant changed the title lsp: Add clangd readonly token modifier to semantic token rules to highlight constant variables as constant. Feb 12, 2026
@ozacod
Copy link
Copy Markdown
Contributor Author

ozacod commented Feb 12, 2026

Do you have any plan to add language specific semantic_tokens.json in the future? @Veykril

Btw, thanks for the incredible work.

@Veykril
Copy link
Copy Markdown
Member

Veykril commented Feb 20, 2026

Sorry for the late reply, for builtin languages we already have that, you can take a look at how rust does it, it has its own json rules file. So we can do the same clangd here

@ozacod
Copy link
Copy Markdown
Contributor Author

ozacod commented Mar 15, 2026

Sorry for the late reply, for builtin languages we already have that, you can take a look at how rust does it, it has its own json rules file. So we can do the same clangd here

I changed the code to add this rule to c++ semantic rules file.

@ozacod ozacod closed this Mar 15, 2026
@ozacod ozacod reopened this Mar 15, 2026
@ozacod ozacod force-pushed the feat/clangd-readonly branch from 9829e35 to 83059af Compare March 15, 2026 22:20
Copy link
Copy Markdown
Member

@Veykril Veykril left a comment

Choose a reason for hiding this comment

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

Thanks!

@Veykril Veykril enabled auto-merge (squash) March 16, 2026 07:23
@Veykril Veykril merged commit e5a69d8 into zed-industries:main Mar 16, 2026
29 checks passed
piper-of-dawn pushed a commit to piper-of-dawn/zed that referenced this pull request Apr 25, 2026
…ghlight constant variables as constant (zed-industries#49065)

Clangd uses the "readonly" token modifier instead of "constant".
Therefore, "readonly" should be mapped to highlight constant variables
as constants.

Before:
<img width="706" height="48" alt="before"
src="https://github.com/user-attachments/assets/8cc2a310-7825-490b-b868-58ea231612fa"
/>

After:
<img width="762" height="46" alt="after"
src="https://github.com/user-attachments/assets/e271d4cd-cc59-45f9-a8b4-2885857915db"
/>

- [x] Code Reviewed
- [x] Manual QA

Release Notes:

- Added clangd readonly token modifier to semantic token rules to
highlight constant variables as constant.

Co-authored-by: ozacod <ozacod@users.noreply.github.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

2 participants