Skip to content
This repository has been archived by the owner on Sep 24, 2024. It is now read-only.

Support for clangd #14

Closed
arrufat opened this issue Sep 27, 2019 · 10 comments
Closed

Support for clangd #14

arrufat opened this issue Sep 27, 2019 · 10 comments

Comments

@arrufat
Copy link

arrufat commented Sep 27, 2019

Hi! I've been using your plugin with coc.nvim and ccls and it works great.

However, I've seen that a lot of development efforts are put into clangd these days, so I was wondering, now that clangd supports semantic highlighting, would it be possible to add support for it?

Thanks again :)

@jackguo380
Copy link
Owner

Hi arrufat,

I did know about the proposed support for semantic highlighting but didn't know clangd added support for it in LLVM 9 thanks for letting me know.

I see that vim-lsp has a PR to support it (prabirshrestha/vim-lsp#464) which has yet to be merged. I tried pulling it locally but it seems to be very WIP as all the symbols turned black regardless of my colorscheme.

I would like to add support for it however the spec is completely different from what ccls (and cquery) implements. There are a couple of things blocking it as well:

  • By default semantic highlighting is not sent to the client (ccls always sends semantic highlighting, cquery allows enabling it in initializationOptions).
    • The client must advertise it's capable of it in ClientCapabilities and then parse the "scopes" in ServerCapabilities.
    • This requires vim-lsp-cxx-highlight to do stuff with ClientCapabilities and ServerCapabilities. As far as I have seen none of the currently supported LSP clients allow another plugin to modify those. There seems to be no way to enable it in a configuration file like .vimrc or init.vim as well.

TL;DR Currently theres no way to add support for clangd's semantic highlighting without modifying each supported LSP client.

Note to self:
https://github.com/microsoft/vscode-languageserver-node/blob/5a9b33c23de84c3341e011e79221795a8059375b/protocol/src/protocol.semanticHighlighting.proposed.md
autozimu/LanguageClient-neovim#383
microsoft/language-server-protocol#18

@arrufat
Copy link
Author

arrufat commented Sep 27, 2019

Oh, thank you for providing all those details.
I understand what you're saying, and right now it doesn't seem obvious.
Anyway, ccls works great, but I was just wondering, because that project is mostly a one-man-effort, and clangd will have many useful features, such as clang-format and clang-tidy integration.
Thank you again for the reply, feel free to close the issue if you think it's not relevant yet :)

@jackguo380
Copy link
Owner

This is somewhat relevant to this issue:

I just submitted a PR autozimu/LanguageClient-neovim#954 to add support for the proposed semantic highlighting protocol which would enable semantic highlighting using clangd.

It looks like vim-lsp also has merged prabirshrestha/vim-lsp#464, which would do the same thing.

@arrufat I can't seem to find any official issue for semantic highlighting on coc.nvim, consider submitting one. If all of the top LSP clients implement the protocol it would help push it into the standard faster. (I would submit a PR but I don't know any typescript :/).

@wbthomason
Copy link

Is the state of this issue still blocked on getting semantic highlighting adopted in the LSP standard & implemented by the major clients?

@jackguo380
Copy link
Owner

Yes, there's currently no good way to receive the semantic highlighting notifications from clangd. The main issue is that without the LSP client advertising that it is capable of semantic highlighting the server doesn't send it. Theres no way to modify the capabilities without modifying the source code, so overall theres nothing the user can do to turn on these notifications.

It would have been feasible to add support if clangd had an option in initializationOptions like cquery does but from at the docs theres nothing.

If you use vim-lsp or LanguageClient-neovim they both should work with clangd but otherwise you would probably have to go bug the authors of your LSP client to add support.

@fannheyward
Copy link

Hello @jackguo380 , I'm working on add semanticHighlighting for clangd by coc.nvim+coc-clangd. I need some help on the symbol format, can you or anyone help? clangd/coc-clangd#27

@fannheyward
Copy link

Hello, coc-clangd has added semanticHighlighting for clangd. You need to install coc.nvim with coc-clangd, and set "clangd.semanticHighlighting": true to enable it.

@jackguo380
Copy link
Owner

@arrufat @wbthomason vim-lsp-cxx-highlight now supports clangd, see the previous comment and the updated README for instructions. If this works for you then please close the issue.

Thank you for your great work @fannheyward

@wbthomason
Copy link

@jackguo380 It's working for me! Thanks very much to you and @fannheyward.

I'm deferring to @arrufat to close the issue, as he was the originator.

@arrufat
Copy link
Author

arrufat commented Mar 25, 2020

@wbthomason, thank you so much!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants