emacs-lsp / lsp-mode

Emacs client/library for the Language Server Protocol
https://emacs-lsp.github.io/lsp-mode
GNU General Public License v3.0
4.77k stars 882 forks source link

Extend lsp-clangd to include protocol extension #2279

Open petr-tik opened 3 years ago

petr-tik commented 3 years ago

Clangd has several extensions introduced at different versions. After the clangd executable is found, we can check what version is running and enable everything <= found version.

Personally, I am most interested in these extensions (descending order of preference):

https://clangd.llvm.org/extensions.html

kiennq commented 3 years ago

The code completion scores stuff has been supported.

petr-tik commented 3 years ago

I wanted to add a SampleCppProject with CMakeLists to test lsp-clangd.

Is that ok or do you think this is too heavy a dependency (cmake + clangd) to install in our CI?

yyoncho commented 3 years ago

Depends on how much will slow down the CI. My guess is that it will be fine

petr-tik commented 3 years ago

sounds great - i will be honest I have never written elisp tests, so they might be naive, but I look forward to your feedback

petr-tik commented 3 years ago

Since the code completion scores is already done, I am going to tackle the "Switch between source/header" function and use it to write some tests too

nbfalcon commented 3 years ago

Why are there two "Compilation commands" checkboxes? Aside from that, what do you mean by inline fixes for diagnostics? Flycheck doesn't support fixes.

nbfalcon commented 3 years ago

FYI, there is also projectile-find-other-file to switch between source/header.

nbfalcon commented 3 years ago

Compilation commands also kind of doesn't make sense, since Emacs is not an Editor with a strong sense of project configuration like say Eclipse. There are no project settings, meaning that clangd would end up relying on the compile_commands.json anyway.

yyoncho commented 3 years ago

FYI, there is also projectile-find-other-file to switch between source/header.

the clangd version will be faster and more precise.

Aside from that, what do you mean by inline fixes for diagnostics? Flycheck doesn't support fixes.

We do have quick fixes in lsp-treemacs-errors-list. Also, I think that the overall idea is to save one call to the server. But then all diagnostics will receive the code actions as well. Which will increase the traffic.

petr-tik commented 3 years ago

FYI, there is also projectile-find-other-file to switch between source/header.

the clangd version will be faster and more precise.

That's precisely my reasoning and lsp-mode should present major lsp servers' full capabilities, instead of relying on projectile for some LSP requests.

Aside from that, what do you mean by inline fixes for diagnostics? Flycheck doesn't support fixes.

But then all diagnostics will receive the code actions as well. Which will increase the traffic.

Do you expect this increase in traffic to be significant?

yyoncho commented 3 years ago

Aside from that, what do you mean by inline fixes for diagnostics? Flycheck doesn't support fixes.

But then all diagnostics will receive the code actions as well. Which will increase the traffic.

Do you expect this increase in traffic to be significant?

It all depends on the number of errors/code actions per error and the refresh pattern of the clangd. JDTLS, for example, refreshes all diagnostics in all files when you change a file. Considering that more traffic puts more pressure on GC and also that the only benefit seems to be the fact that you will avoid document/codeActions which will be very fast as well I would say that the effect from implementing support for that won't be visible at all.