aboutsummaryrefslogtreecommitdiffstats
path: root/lua
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2024-10-18 06:47:24 -0700
committerGitHub <noreply@github.com>2024-10-18 06:47:24 -0700
commitd6b0c3b38cdb45dcbd658efc2bb721568f68d93f (patch)
treec9762439b37807a70379ddbe9b7d0deacd0ab7ab /lua
parentdocs: update configs.md (diff)
downloadnvim-lspconfig-d6b0c3b38cdb45dcbd658efc2bb721568f68d93f.tar
nvim-lspconfig-d6b0c3b38cdb45dcbd658efc2bb721568f68d93f.tar.gz
nvim-lspconfig-d6b0c3b38cdb45dcbd658efc2bb721568f68d93f.tar.bz2
nvim-lspconfig-d6b0c3b38cdb45dcbd658efc2bb721568f68d93f.tar.lz
nvim-lspconfig-d6b0c3b38cdb45dcbd658efc2bb721568f68d93f.tar.xz
nvim-lspconfig-d6b0c3b38cdb45dcbd658efc2bb721568f68d93f.tar.zst
nvim-lspconfig-d6b0c3b38cdb45dcbd658efc2bb721568f68d93f.zip
feat(lspinfo): also show version in make_client_info #3382
Problem: version is only printed for make_config_info. Solution: Add it to make_client_info.
Diffstat (limited to 'lua')
-rw-r--r--lua/lspconfig/health.lua13
1 files changed, 8 insertions, 5 deletions
diff --git a/lua/lspconfig/health.lua b/lua/lspconfig/health.lua
index d0145751..aa9b9a29 100644
--- a/lua/lspconfig/health.lua
+++ b/lua/lspconfig/health.lua
@@ -39,14 +39,14 @@ end
--- If a version string is not found, returns the concatenated output.
---
--- @param cmd string[]
-local function try_get_version(cmd)
+local function try_fmt_version(cmd)
local out = vim.fn.system(cmd)
if not out then
return nil
end
- local version_line = out:match('[^\r\n]+%d+%.[0-9.]+[^\r\n]+')
- local s = vim.trim(version_line and version_line or out:gsub('[\r\n]', ' '))
- return s
+ local v_line = out:match('[^\r\n]+%d+%.[0-9.]+[^\r\n]+')
+ local fallback = ('`%s` (output of `%s`)'):format(out:gsub('[\r\n]', ' '), table.concat(cmd, ' '))
+ return vim.trim(v_line and ('`%s`'):format(v_line) or fallback)
end
--- Prettify a path for presentation.
@@ -125,7 +125,7 @@ local function make_config_info(config, bufnr)
'filetypes: ' .. config_info.filetypes,
'root directory: ' .. fmtpath(config_info.root_dir),
'cmd: ' .. fmtpath(config_info.cmd),
- ('%-18s `%s`'):format('version:', try_get_version(cmd_version)),
+ ('%-18s %s'):format('version:', try_fmt_version(cmd_version)),
'cmd is executable: ' .. config_info.cmd_is_executable,
'autostart: ' .. config_info.autostart,
'custom handlers: ' .. config_info.handlers,
@@ -175,6 +175,8 @@ local function make_client_info(client, fname)
client_info.autostart = (client.config.autostart and 'true') or 'false'
client_info.attached_buffers_list = table.concat(vim.lsp.get_buffers_by_client_id(client.id), ', ')
+ local cmd_version = { client_info.cmd, '--version' }
+
local lines = {
'Client: '
.. client.name
@@ -189,6 +191,7 @@ local function make_client_info(client, fname)
'filetypes: ' .. client_info.filetypes,
'root directory: ' .. fmtpath(client_info.root_dir),
'cmd: ' .. fmtpath(client_info.cmd),
+ ('%-18s %s'):format('version:', try_fmt_version(cmd_version)),
'autostart: ' .. client_info.autostart,
}