Skip to content

Commit

Permalink
fix(health): "attempt to index cmd (function)" #3390
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
justinmk authored Oct 20, 2024
1 parent fd49d58 commit 84f8677
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lua/lspconfig/health.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down

0 comments on commit 84f8677

Please sign in to comment.