aboutsummaryrefslogtreecommitdiffstats
path: root/lua
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2024-10-20 11:56:47 -0700
committerGitHub <noreply@github.com>2024-10-20 11:56:47 -0700
commit84f867753f659bfd9319f75bd5eb273a315f2da5 (patch)
tree914f91e2da2943d4bd82f958eb54f97b725290e6 /lua
parentfix(health): improve version reporting #3388 (diff)
downloadnvim-lspconfig-84f867753f659bfd9319f75bd5eb273a315f2da5.tar
nvim-lspconfig-84f867753f659bfd9319f75bd5eb273a315f2da5.tar.gz
nvim-lspconfig-84f867753f659bfd9319f75bd5eb273a315f2da5.tar.bz2
nvim-lspconfig-84f867753f659bfd9319f75bd5eb273a315f2da5.tar.lz
nvim-lspconfig-84f867753f659bfd9319f75bd5eb273a315f2da5.tar.xz
nvim-lspconfig-84f867753f659bfd9319f75bd5eb273a315f2da5.tar.zst
nvim-lspconfig-84f867753f659bfd9319f75bd5eb273a315f2da5.zip
fix(health): "attempt to index cmd (function)" #3390
Problem: `cmd` may be a random function instead of an executable command. ERROR Failed to run healthcheck for "lspconfig" plugin. Exception: .../lua/lspconfig/health.lua:127: attempt to index field 'cmd' (a function value) Solution: Skip attempt to invoke `<cmd> --version` if `cmd` is a function.
Diffstat (limited to 'lua')
-rw-r--r--lua/lspconfig/health.lua3
1 files changed, 2 insertions, 1 deletions
diff --git a/lua/lspconfig/health.lua b/lua/lspconfig/health.lua
index 0b2432e3..74a35655 100644
--- a/lua/lspconfig/health.lua
+++ b/lua/lspconfig/health.lua
@@ -121,10 +121,11 @@ local function make_info(config_or_client)
info.autostart = (config.autostart and 'true') or 'false'
info.filetypes = table.concat(config.filetypes or {}, ', ')
+ local version = type(config.cmd) == 'function' and '? (cmd is a function)' or try_fmt_version(config.cmd[1])
local info_lines = {
'filetypes: ' .. info.filetypes,
'cmd: ' .. fmtpath(info.cmd_desc),
- ('%-18s %s'):format('version:', try_fmt_version(config.cmd[1])),
+ ('%-18s %s'):format('version:', version),
'executable: ' .. info.cmd_is_executable,
'autostart: ' .. info.autostart,
}