From d1bc6fca7123d77ebf03d0badd63f930a5b74064 Mon Sep 17 00:00:00 2001 From: Bogdan Grigoruță <43993819+krady21@users.noreply.github.com> Date: Sun, 24 Sep 2023 21:43:16 +0300 Subject: feat(health): list attached buffers in LSP report #23561 Problem: Users using `vim.lsp.start` directly (instead of nvim-lspconfig) need more visibility for troubleshooting. For example, troubleshooting unnecesary servers or servers that aren't attaching to expected buffers. Solution: Mention attached buffers in the `:checkhealth lsp` report. Example: vim.lsp: Active Clients ~ - clangd (id=1, root_dir=~/dev/neovim, attached_to=[7]) - lua_ls (id=2, root_dir=~/dev/neovim, attached_to=[10]) --- runtime/lua/vim/lsp/health.lua | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'runtime/lua/vim/lsp') diff --git a/runtime/lua/vim/lsp/health.lua b/runtime/lua/vim/lsp/health.lua index 023b1c26be..fe06006108 100644 --- a/runtime/lua/vim/lsp/health.lua +++ b/runtime/lua/vim/lsp/health.lua @@ -32,8 +32,15 @@ function M.check() vim.health.start('vim.lsp: Active Clients') if next(clients) then for _, client in pairs(clients) do + local attached_to = table.concat(vim.tbl_keys(client.attached_buffers or {}), ',') report_info( - string.format('%s (id=%s, root_dir=%s)', client.name, client.id, client.config.root_dir) + string.format( + '%s (id=%s, root_dir=%s, attached_to=[%s])', + client.name, + client.id, + vim.fn.fnamemodify(client.config.root_dir, ':~'), + attached_to + ) ) end else -- cgit