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

nvim-lsp and clangd combination doesn't work under nvim 0.5.0 #33

Closed MuAlphaOmegaEpsilon closed 4 years ago

MuAlphaOmegaEpsilon commented 4 years ago

Describe the bug

Intent I would like to use this plugin in combination with nvim-lsp and clangd, which is the LSP server that I am actually using. The plugin is correctly loaded, as it appears under the list generated by :scriptnames.

To Reproduce

$ mkdir -p /home/user/.local/share/nvim/site/pack/git-plugins/start
$ cd /home/user/.local/share/nvim/site/pack/git-plugins/start
$ git submodule add git@github.com:jackguo380/vim-lsp-cxx-highlight
$ nvim /home/user/.local/share/nvim/site/plugin/nvim-lsp.vim # adding setup instructions for clangd
$ nvim /home/user/file.cpp
:help vim-lsp-cxx-highlight

Expected behavior The highlighting should actually work. Symbols related commands should return a non-empty list. The plugin help should show up.

Configuration (Fill this out):

Log File:

mar 2 giu 2020, 19:39:30: lsp_cxx_hl beginning initialization...
mar 2 giu 2020, 19:39:30: vim-lsp not detected
mar 2 giu 2020, 19:39:30: LanguageClient-neovim not detected
mar 2 giu 2020, 19:39:30: coc.nvim not detected
mar 2 giu 2020, 19:39:30: nvim-lsp successfully registered
jackguo380 commented 4 years ago

Hi, as mentioned in the readme, clangd is only supported when you are using coc.nvim with coc-clangd. I don't plan on implementing it either for reasons stated in #14, tl;dr its too hard/impossible without the LSP client allowing a third-party plugin control over negotation with the server.

As for why :help isn't working, its probably to do with needing to generate helptags since you are using the builtin plugin manager rather than something like vim-plug which does it automatically.

MuAlphaOmegaEpsilon commented 4 years ago

Oh, reading the README.md I thought coc-clangd was necessary only if using coc.nvim... Clangd at the moment is supported by nvim-lsp, so I thought that by leveraging the latter it would be possible to also support the former.

Ok, I'm not aware of helptags, but I'll dig into that.

Give me a shout if one day or another you integrate clangd into this plugin, because I would be really interested in that.

Thank you!

jackguo380 commented 4 years ago

Technically all LSP clients support all LSP servers to some degree since that is the goal of the protocol. But unfortunately since the protocol is so slow to standardize things (semantic highlighting in particular), various servers have added non-standard extensions for various features. Even though nvim-lsp works well with clangd for completion and code navigation it won't work with clangd's semantic highlighting since its a different protocol from what is currently standardized.

Here are the options if you are looking for semantic highlighting:

MuAlphaOmegaEpsilon commented 4 years ago

Thank you for your time and tips!

tobias-vde commented 4 years ago

Here are the options if you are looking for semantic highlighting:

* Wait for semantic highlighting to become part of the standard, at that point nvim-lsp will have to implement it.

* Switch to `coc.nvim` for your LSP client, if you prefer `clangd` over `ccls`

* Switch to `ccls` as your LSP server since it works with all the clients vim-lsp-cxx-highlight works with.

+another option: Have a look at treesitter (for neovim: nvim-treesitter), it's not perfect (yet), but I think it could provide the highlighting you are looking for + some handy extra features, and personally, it "feels" more "accurate" than the clangd highlighting. It's being implemented into neovim right now. Below is a screenshot comparing different plugins/highlighters: 2020-09-13_03-28-217540993 Top right is nvim-treesitter, bottom right is LanguageClient-Neovim + clangd.

EDIT: nvim-treesitter bug seems to be fixed in their latest release, my bad...