Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(semantic_tokens): link lsp comments, e.g. conditional C ifdefs that won't evaluate #334

Merged
merged 1 commit into from
Mar 14, 2023

Conversation

amaanq
Copy link
Contributor

@amaanq amaanq commented Mar 13, 2023

Before:
image

After:
image

Would be very useful for C/C++ devs

@amaanq
Copy link
Contributor Author

amaanq commented Mar 13, 2023

reorganized lsp tokens list by alphabetical order

@clason
Copy link

clason commented Mar 14, 2023

That (comment) should be a default link in Neovim. (There may also be some modifiers that could usefully linked by default.)

@folke
Copy link
Owner

folke commented Mar 14, 2023

I'm not 100% convinced about this change, but it's fine by me.
Can you change it to link to @comment instead?

@amaanq
Copy link
Contributor Author

amaanq commented Mar 14, 2023

It's nice for C/C++ macros to have inactive sections highlighted as comments, and it's quite common in most IDEs

Updated to link to @comment

@folke folke merged commit b233a3c into folke:main Mar 14, 2023
@folke
Copy link
Owner

folke commented Mar 14, 2023

awesome, thanks!

@swarn
Copy link

swarn commented Mar 14, 2023

Just FYI: The reason that @lsp.type.comment is not default-linked to Comment is that, for servers like luaLS, the @lsp.type.comment highlight will hide useful treesitter highlights. For example, TODO inside comments is highlighted with @text.todo.comment, which will be hidden by the semantic highlight.

Notably, clangd only uses the comment token for #if 0 style preprocessor blocks, and not for actual comments, so linking @lsp.type.comment.c and @lsp.type.comment.cpp to @comment will not hide useful treesitter highlighting.

@amaanq
Copy link
Contributor Author

amaanq commented Mar 14, 2023

Just FYI: The reason that @lsp.type.comment is not default-linked to Comment is that, for servers like luaLS, the @lsp.type.comment highlight will hide useful treesitter highlights. For example, TODO inside comments is highlighted with @text.todo.comment, which will be hidden by the semantic highlight.

Notably, clangd only uses the comment token for #if 0 style preprocessor blocks, and not for actual comments, so linking @lsp.type.comment.c and @lsp.type.comment.cpp to @comment will not hide useful treesitter highlighting.

Thanks for the headsup, and I'm sorry about that! I don't use treesitter's comments so I hadn't noticed that. I would totally be open to changing this only for c/cpp files, I do think such a case should be somewhat separate from regular comments anyways which I'm glad clangd does by not producing comment tokens for actual comments.

riley-martine pushed a commit to riley-martine/tokyonight.nvim that referenced this pull request Dec 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants