From 3f1bbaad4ee4bb026e8b844261b0bff00f72f06c Mon Sep 17 00:00:00 2001 From: Hirokazu Hata Date: Sat, 22 Feb 2020 10:53:09 +0900 Subject: healthcheck: use pcall --- lua/nvim_lsp/health.lua | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'lua') diff --git a/lua/nvim_lsp/health.lua b/lua/nvim_lsp/health.lua index 584b1cfc..f319a265 100644 --- a/lua/nvim_lsp/health.lua +++ b/lua/nvim_lsp/health.lua @@ -4,17 +4,23 @@ function M.check_health() for _, top_level_config in pairs(configs) do -- the folder needs to exist - local new_config = top_level_config.make_config(".") + local config = top_level_config.make_config(".") - local cmd, _ = vim.lsp._cmd_parts(new_config.cmd) - if not (vim.fn.executable(cmd) == 1) then + local status, cmd = pcall(vim.lsp._cmd_parts, config.cmd) + if not status then vim.fn['health#report_error']( - string.format("%s: The given command %q is not executable.", new_config.name, cmd) + string.format("%s: config.cmd error, %s", config.name, cmd) ) else - vim.fn['health#report_info']( - string.format("%s: configuration checked.", new_config.name) - ) + if not (vim.fn.executable(cmd) == 1) then + vim.fn['health#report_error']( + string.format("%s: The given command %q is not executable.", config.name, cmd) + ) + else + vim.fn['health#report_info']( + string.format("%s: configuration checked.", config.name) + ) + end end end end -- cgit v1.2.3-70-g09d2