aboutsummaryrefslogtreecommitdiffstats
path: root/lua
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2024-10-18 14:16:29 +0200
committerJustin M. Keyes <justinkz@gmail.com>2024-10-18 14:20:14 +0200
commit2c812ad934d6d1a89fe608d164e2b6ce7d31d4f2 (patch)
treecafe1bf7e3161f11e8271d51a89450d4e958b0fa /lua
parentfix(lspinfo)!: remove config.lspinfo (diff)
downloadnvim-lspconfig-2c812ad934d6d1a89fe608d164e2b6ce7d31d4f2.tar
nvim-lspconfig-2c812ad934d6d1a89fe608d164e2b6ce7d31d4f2.tar.gz
nvim-lspconfig-2c812ad934d6d1a89fe608d164e2b6ce7d31d4f2.tar.bz2
nvim-lspconfig-2c812ad934d6d1a89fe608d164e2b6ce7d31d4f2.tar.lz
nvim-lspconfig-2c812ad934d6d1a89fe608d164e2b6ce7d31d4f2.tar.xz
nvim-lspconfig-2c812ad934d6d1a89fe608d164e2b6ce7d31d4f2.tar.zst
nvim-lspconfig-2c812ad934d6d1a89fe608d164e2b6ce7d31d4f2.zip
feat(lspinfo): print `<cmd> --version` result
Diffstat (limited to 'lua')
-rw-r--r--lua/lspconfig/health.lua18
1 files changed, 18 insertions, 0 deletions
diff --git a/lua/lspconfig/health.lua b/lua/lspconfig/health.lua
index d3bc93b8..d0145751 100644
--- a/lua/lspconfig/health.lua
+++ b/lua/lspconfig/health.lua
@@ -34,6 +34,21 @@ local function remove_newlines(cmd)
return cmd
end
+--- Finds a "x.y.z" version string from the output of `cmd`, and returns the whole line.
+---
+--- If a version string is not found, returns the concatenated output.
+---
+--- @param cmd string[]
+local function try_get_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
+end
+
--- Prettify a path for presentation.
local function fmtpath(p)
if vim.startswith(p, 'Running') then
@@ -104,10 +119,13 @@ local function make_config_info(config, bufnr)
'Config: ' .. config_info.name,
}
+ local cmd_version = { config_info.cmd, '--version' }
+
local info_lines = {
'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)),
'cmd is executable: ' .. config_info.cmd_is_executable,
'autostart: ' .. config_info.autostart,
'custom handlers: ' .. config_info.handlers,