From 2db8a342dab5f135e8f9d80d520ce56bf83da667 Mon Sep 17 00:00:00 2001 From: Hirokazu Hata Date: Sun, 24 May 2020 10:22:58 +0900 Subject: healthcheck: skip healthcheck if make_config function is nil resolve https://github.com/neovim/nvim-lsp/issues/248 --- lua/nvim_lsp/health.lua | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) (limited to 'lua/nvim_lsp') diff --git a/lua/nvim_lsp/health.lua b/lua/nvim_lsp/health.lua index f319a265..d0e5820e 100644 --- a/lua/nvim_lsp/health.lua +++ b/lua/nvim_lsp/health.lua @@ -3,23 +3,21 @@ function M.check_health() local configs = require 'nvim_lsp/configs' for _, top_level_config in pairs(configs) do - -- the folder needs to exist - local config = top_level_config.make_config(".") + -- If users execute `:LspInstall` or `:LspInstallInfo`, + -- a config is required but is not added make_config function. + if not (top_level_config.make_config == nil) then + -- the folder needs to exist + local config = top_level_config.make_config(".") - local status, cmd = pcall(vim.lsp._cmd_parts, config.cmd) - if not status then - vim.fn['health#report_error']( - string.format("%s: config.cmd error, %s", config.name, cmd) - ) - else - 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) - ) + local status, cmd = pcall(vim.lsp._cmd_parts, config.cmd) + if not status then + vim.fn['health#report_error'](string.format("%s: config.cmd error, %s", config.name, cmd)) else - vim.fn['health#report_info']( - string.format("%s: configuration checked.", 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