From 84f867753f659bfd9319f75bd5eb273a315f2da5 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sun, 20 Oct 2024 11:56:47 -0700 Subject: 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 ` --version` if `cmd` is a function. --- lua/lspconfig/health.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lua') 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, } -- cgit v1.2.3-70-g09d2