mirror of
				https://github.com/neovim/neovim.git
				synced 2025-11-04 01:34:25 +00:00 
			
		
		
		
	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])
			
			
This commit is contained in:
		@@ -32,8 +32,15 @@ function M.check()
 | 
				
			|||||||
  vim.health.start('vim.lsp: Active Clients')
 | 
					  vim.health.start('vim.lsp: Active Clients')
 | 
				
			||||||
  if next(clients) then
 | 
					  if next(clients) then
 | 
				
			||||||
    for _, client in pairs(clients) do
 | 
					    for _, client in pairs(clients) do
 | 
				
			||||||
 | 
					      local attached_to = table.concat(vim.tbl_keys(client.attached_buffers or {}), ',')
 | 
				
			||||||
      report_info(
 | 
					      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
 | 
					    end
 | 
				
			||||||
  else
 | 
					  else
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user