1
mirror of https://github.com/neovim/neovim.git synced 2024-12-27 14:21:31 -07:00

feat(lsp): show server version in :checkhealth

Problem:
Language server version information missing from `:checkhealth vim.lsp`.

Solution:
Store `InitializeResult.serverInfo.version` from the `initialize`
response and display for each client in `:checkhealth vim.lsp`.
This commit is contained in:
Peter Lithammer 2024-12-18 15:31:25 +01:00 committed by GitHub
parent f9eb68f340
commit 07d5dc8938
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 13 additions and 0 deletions

View File

@ -1126,6 +1126,9 @@ Lua module: vim.lsp.client *lsp-client*
• {server_capabilities} (`lsp.ServerCapabilities?`) Response from the • {server_capabilities} (`lsp.ServerCapabilities?`) Response from the
server sent on `initialize` describing the server sent on `initialize` describing the
server's capabilities. server's capabilities.
• {server_info} (`lsp.ServerInfo?`) Response from the server
sent on `initialize` describing information
about the server.
• {progress} (`vim.lsp.Client.Progress`) A ring buffer • {progress} (`vim.lsp.Client.Progress`) A ring buffer
(|vim.ringbuf()|) containing progress messages (|vim.ringbuf()|) containing progress messages
sent by the server. See sent by the server. See

View File

@ -115,6 +115,7 @@ LSP
• |vim.lsp.util.make_position_params()|, |vim.lsp.util.make_range_params()| • |vim.lsp.util.make_position_params()|, |vim.lsp.util.make_range_params()|
and |vim.lsp.util.make_given_range_params()| now require the `position_encoding` and |vim.lsp.util.make_given_range_params()| now require the `position_encoding`
parameter. parameter.
• `:checkhealth vim.lsp` displays the server version (if available).
LUA LUA

View File

@ -174,6 +174,10 @@ local validate = vim.validate
--- capabilities. --- capabilities.
--- @field server_capabilities lsp.ServerCapabilities? --- @field server_capabilities lsp.ServerCapabilities?
--- ---
--- Response from the server sent on `initialize` describing information about
--- the server.
--- @field server_info lsp.ServerInfo?
---
--- A ring buffer (|vim.ringbuf()|) containing progress messages --- A ring buffer (|vim.ringbuf()|) containing progress messages
--- sent by the server. --- sent by the server.
--- @field progress vim.lsp.Client.Progress --- @field progress vim.lsp.Client.Progress
@ -556,6 +560,8 @@ function Client:initialize()
self.offset_encoding = self.server_capabilities.positionEncoding self.offset_encoding = self.server_capabilities.positionEncoding
end end
self.server_info = result.serverInfo
if next(self.settings) then if next(self.settings) then
self:notify(ms.workspace_didChangeConfiguration, { settings = self.settings }) self:notify(ms.workspace_didChangeConfiguration, { settings = self.settings })
end end

View File

@ -40,6 +40,8 @@ local function check_active_clients()
local clients = vim.lsp.get_clients() local clients = vim.lsp.get_clients()
if next(clients) then if next(clients) then
for _, client in pairs(clients) do for _, client in pairs(clients) do
local server_version = vim.tbl_get(client, 'server_info', 'version')
or '? (no serverInfo.version response)'
local cmd ---@type string local cmd ---@type string
local ccmd = client.config.cmd local ccmd = client.config.cmd
if type(ccmd) == 'table' then if type(ccmd) == 'table' then
@ -62,6 +64,7 @@ local function check_active_clients()
end end
report_info(table.concat({ report_info(table.concat({
string.format('%s (id: %d)', client.name, client.id), string.format('%s (id: %d)', client.name, client.id),
string.format('- Version: %s', server_version),
dirs_info, dirs_info,
string.format('- Command: %s', cmd), string.format('- Command: %s', cmd),
string.format('- Settings: %s', vim.inspect(client.settings, { newline = '\n ' })), string.format('- Settings: %s', vim.inspect(client.settings, { newline = '\n ' })),