aboutsummaryrefslogtreecommitdiffstats
path: root/lua
diff options
context:
space:
mode:
authorHirokazu Hata <h.hata.ai.t@gmail.com>2020-02-22 10:53:09 +0900
committerHirokazu Hata <h.hata.ai.t@gmail.com>2020-03-05 10:42:58 +0900
commit3f1bbaad4ee4bb026e8b844261b0bff00f72f06c (patch)
treead71fb6527e25d55fa112422d9c5ad9b82a25cb4 /lua
parent[docgen] Update README.md (diff)
downloadnvim-lspconfig-3f1bbaad4ee4bb026e8b844261b0bff00f72f06c.tar
nvim-lspconfig-3f1bbaad4ee4bb026e8b844261b0bff00f72f06c.tar.gz
nvim-lspconfig-3f1bbaad4ee4bb026e8b844261b0bff00f72f06c.tar.bz2
nvim-lspconfig-3f1bbaad4ee4bb026e8b844261b0bff00f72f06c.tar.lz
nvim-lspconfig-3f1bbaad4ee4bb026e8b844261b0bff00f72f06c.tar.xz
nvim-lspconfig-3f1bbaad4ee4bb026e8b844261b0bff00f72f06c.tar.zst
nvim-lspconfig-3f1bbaad4ee4bb026e8b844261b0bff00f72f06c.zip
healthcheck: use pcall
Diffstat (limited to 'lua')
-rw-r--r--lua/nvim_lsp/health.lua20
1 files changed, 13 insertions, 7 deletions
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