neovim / nvim-lspconfig

Quickstart configs for Nvim LSP
Apache License 2.0
10.82k stars 2.1k forks source link

can :LspInfo (:checkhealth lspconfig) show more detailed info? #3376

Open justinmk opened 1 month ago

justinmk commented 1 month ago

Description

https://github.com/neovim/nvim-lspconfig/pull/3375 removes an undocumented config.lspinfo extension point that was intended to allow config-specific augmentation of the LspInfo report. Can information such as tool versions be derived from LSP client info and/or server responses instead?

Example use case: https://github.com/neovim/nvim-lspconfig/pull/1693 which wants to report the "project file".

Proposal

suggested by @glacambre :

Could a new field be added to language server configurations listing additional workspace/executeCommand requests that would be nice to perform on :LspInfo? Then the als' configuration could have als-project-file in that field, and Neovim could display the result of that request as a string in LspInfo's buffer.

Maybe vim.lsp.Client could have a statusCmds: string[] field which defines how "status" can be reported by a server.

glepnir commented 1 month ago

Can information such as tool versions be derived from the LSP server response instead?

No way lsp spec doesn't have a method to get information of server instead :!clangd --version not enough ? the only usage of config.lspinfo is in hls..so i think you don't need worry about there..

justinmk commented 1 month ago

updated proposal. clangd --version requires config-specific stuff and doesn't address things like https://github.com/neovim/nvim-lspconfig/pull/1693 which wants to report the "project file".

glepnir commented 1 month ago

aha okay so can we add a health field instead of lspinfo in configs ? this can lead more users to pay attention to checkhealth . default use info level is enought health_info(table.concat(configs.health()), '\n')

justinmk commented 1 month ago

add a health field instead of lspinfo in configs

No. That wouldn't be any different than the existing config.lspinfo field.

What I'm asking is first, what info does the LSP client already know, that can be displayed by checkhealth. Does workspace/workspaceFolders report anything useful?

And why isn't root_dir enough to provide what was intended in https://github.com/neovim/nvim-lspconfig/pull/1693 @TamaMcGlinn ? root_dir already defines the *.gpr pattern, so why can't checkhealth use root_dir to say which pattern matched, then report that?

glacambre commented 1 month ago

so why can't checkhealth use root_dir to say which pattern matched, then report that?

Because there could be multiple *.gpr files in a same root directory, so root_dir isn't enough to know which one is being used by the ada language server. In such a case, clients will often use workspace/didChangeConfiguration to select a .gpr file, but storing and re-displaying that information would not work in cases where the client let the server choose a .gpr file.

justinmk commented 1 month ago

instead :!clangd --version not enough ?

Maybe I misunderstood your suggestion. I think LspInfo could just do this automatically, by running [cmd, '--version']. No need to manually bake that into each config, as hls.lua currently does. Done: https://github.com/neovim/nvim-lspconfig/pull/3375 https://github.com/neovim/nvim-lspconfig/pull/3383

WhoIsSethDaniel commented 1 month ago

The output for checkhealth looks pretty bad when the current buffer is attached to gopls since it ends up printing a very large 'help' page (that gopls spits out) as the version for gopls.

gopls only reports the version if you run gopls version.

Is there a way to override how the version check occurs? Or maybe just "version" can be added to the list of options in try_format_version.

justinmk commented 1 month ago

Or maybe just "version" can be added to the list of options in try_format_version.

yes, that is the idea :) PR welcome...

since it ends up printing a very large 'help' page (that gopls spits out)

we should truncate the output. Done: https://github.com/neovim/nvim-lspconfig/pull/3388

spenrose commented 1 month ago

Added version for gopls. #3386

Probably need to add status command to each config.

justinmk commented 1 month ago

Probably need to add status command to each config.

No. If server commands can't be bothered to provide --version, we aren't going to maintain special workarounds for them. They can either provide --version or we will report "failed to get version". It is idiotic that they don't provide --version, or some other common arg to get version/status info.

kaddkaka commented 1 month ago

Could :LspInfo also list root_dir? I have this situation:

pyproject.toml
a.py
test/
  test_a.py
  ruff.toml

ruff.lua lspconfig has this (but also mentions .git in the description, is that a general default?):

local root_files = {
  'pyproject.toml',
  'ruff.toml',
  '.ruff.toml',
}

and I currently don't understand if I'm supposed to see one or two ruff LSP servers launched when I open both a.py and test_a.py

justinmk commented 1 month ago

Could :LspInfo also list root_dir?

Thanks, that was a regression. Fixed in https://github.com/neovim/nvim-lspconfig/pull/3402

nogweii commented 3 weeks ago

Something I'd like to see is whether an LSP has document formatting support. I have a BufWritePre hook that will format the buffer using all available LSPs. Sometimes that doesn't behave in the way I want (e.g. conflicting styles) so I'd like to know which LSPs are being triggered.

I'm not sure this should be included in lspconfig or if a new API should exist to allow end-users to configure additional status functions to be ran for all language servers.