jackguo380 / vim-lsp-cxx-highlight

Vim plugin for C/C++/ObjC semantic highlighting using cquery, ccls, or clangd
MIT License
339 stars 26 forks source link

Support for clangd #14

Closed arrufat closed 4 years ago

arrufat commented 5 years ago

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 commented 5 years ago

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:

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 commented 5 years ago

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 commented 4 years ago

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 commented 4 years ago

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

jackguo380 commented 4 years ago

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 commented 4 years ago

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? https://github.com/clangd/coc-clangd/pull/27

fannheyward commented 4 years ago

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 commented 4 years ago

@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 commented 4 years ago

@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 commented 4 years ago

@wbthomason, thank you so much!