diff options
| author | Justin M. Keyes <justinkz@gmail.com> | 2024-10-18 05:24:06 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-10-18 05:24:06 -0700 |
| commit | 54d1091ca2cc59af6d9e74df3819f48c4372bc1b (patch) | |
| tree | cafe1bf7e3161f11e8271d51a89450d4e958b0fa /lua | |
| parent | refactor: minor cleanup #3379 (diff) | |
| parent | feat(lspinfo): print `<cmd> --version` result (diff) | |
| download | nvim-lspconfig-54d1091ca2cc59af6d9e74df3819f48c4372bc1b.tar nvim-lspconfig-54d1091ca2cc59af6d9e74df3819f48c4372bc1b.tar.gz nvim-lspconfig-54d1091ca2cc59af6d9e74df3819f48c4372bc1b.tar.bz2 nvim-lspconfig-54d1091ca2cc59af6d9e74df3819f48c4372bc1b.tar.lz nvim-lspconfig-54d1091ca2cc59af6d9e74df3819f48c4372bc1b.tar.xz nvim-lspconfig-54d1091ca2cc59af6d9e74df3819f48c4372bc1b.tar.zst nvim-lspconfig-54d1091ca2cc59af6d9e74df3819f48c4372bc1b.zip | |
Merge #3375 from neovim/rmlspinfo
Diffstat (limited to 'lua')
| -rw-r--r-- | lua/lspconfig/configs/hls.lua | 16 | ||||
| -rw-r--r-- | lua/lspconfig/health.lua | 23 |
2 files changed, 18 insertions, 21 deletions
diff --git a/lua/lspconfig/configs/hls.lua b/lua/lspconfig/configs/hls.lua index 4390440d..99426b5e 100644 --- a/lua/lspconfig/configs/hls.lua +++ b/lua/lspconfig/configs/hls.lua @@ -12,22 +12,6 @@ return { cabalFormattingProvider = 'cabalfmt', }, }, - lspinfo = function(cfg) - local extra = {} - local function on_stdout(_, data, _) - local version = data[1] - table.insert(extra, 'version: ' .. version) - end - - local opts = { - cwd = cfg.cwd, - stdout_buffered = true, - on_stdout = on_stdout, - } - local chanid = vim.fn.jobstart({ cfg.cmd[1], '--version' }, opts) - vim.fn.jobwait { chanid } - return extra - end, }, docs = { diff --git a/lua/lspconfig/health.lua b/lua/lspconfig/health.lua index 4af923b2..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, @@ -174,11 +192,6 @@ local function make_client_info(client, fname) 'autostart: ' .. client_info.autostart, } - if client.config.lspinfo then - local server_specific_info = client.config.lspinfo(client.config) - info_lines = vim.list_extend(info_lines, server_specific_info) - end - vim.list_extend(lines, info_lines) return table.concat(lines, '\n') |
