diff options
| author | Matthieu Coudron <mattator@gmail.com> | 2020-02-07 01:15:09 +0100 |
|---|---|---|
| committer | Matthieu Coudron <mattator@gmail.com> | 2020-02-13 18:08:45 +0100 |
| commit | 6b8093c1f18f10a40121ab60957985cbf8da1987 (patch) | |
| tree | 516f2cae2c155a7a69599b1cb8458d69f7f2cb7c /lua | |
| parent | [docgen] Update README.md (diff) | |
| download | nvim-lspconfig-6b8093c1f18f10a40121ab60957985cbf8da1987.tar nvim-lspconfig-6b8093c1f18f10a40121ab60957985cbf8da1987.tar.gz nvim-lspconfig-6b8093c1f18f10a40121ab60957985cbf8da1987.tar.bz2 nvim-lspconfig-6b8093c1f18f10a40121ab60957985cbf8da1987.tar.lz nvim-lspconfig-6b8093c1f18f10a40121ab60957985cbf8da1987.tar.xz nvim-lspconfig-6b8093c1f18f10a40121ab60957985cbf8da1987.tar.zst nvim-lspconfig-6b8093c1f18f10a40121ab60957985cbf8da1987.zip | |
checkhealth: add checkhealth nvim_lsp command
Only check command for now
Diffstat (limited to 'lua')
| -rw-r--r-- | lua/nvim_lsp/configs.lua | 12 | ||||
| -rw-r--r-- | lua/nvim_lsp/health.lua | 22 | ||||
| -rw-r--r-- | lua/nvim_lsp/util.lua | 5 |
3 files changed, 34 insertions, 5 deletions
diff --git a/lua/nvim_lsp/configs.lua b/lua/nvim_lsp/configs.lua index 7733bf42..477eb6a3 100644 --- a/lua/nvim_lsp/configs.lua +++ b/lua/nvim_lsp/configs.lua @@ -93,7 +93,8 @@ function configs.__newindex(t, config_name, config_def) end M.manager = nil end - local manager = util.server_per_root_dir_manager(function(_root_dir) + + local make_config = function(_root_dir) local new_config = vim.tbl_extend("keep", {}, config) -- Deepcopy anything that is >1 level nested. new_config.settings = vim.deepcopy(new_config.settings) @@ -146,8 +147,14 @@ function configs.__newindex(t, config_name, config_def) )) end end) + + new_config.root_dir = _root_dir return new_config - end) + end + + local manager = util.server_per_root_dir_manager(function(_root_dir) + return make_config(_root_dir) + end) function manager.try_add() local root_dir = get_root_dir(api.nvim_buf_get_name(0), api.nvim_get_current_buf()) @@ -159,6 +166,7 @@ function configs.__newindex(t, config_name, config_def) end M.manager = manager + M.make_config = make_config end function M._setup_buffer(client_id) diff --git a/lua/nvim_lsp/health.lua b/lua/nvim_lsp/health.lua new file mode 100644 index 00000000..584b1cfc --- /dev/null +++ b/lua/nvim_lsp/health.lua @@ -0,0 +1,22 @@ +local M = {} +function M.check_health() + local configs = require 'nvim_lsp/configs' + + for _, top_level_config in pairs(configs) do + -- the folder needs to exist + local new_config = top_level_config.make_config(".") + + local cmd, _ = vim.lsp._cmd_parts(new_config.cmd) + if not (vim.fn.executable(cmd) == 1) then + vim.fn['health#report_error']( + string.format("%s: The given command %q is not executable.", new_config.name, cmd) + ) + else + vim.fn['health#report_info']( + string.format("%s: configuration checked.", new_config.name) + ) + end + end +end + +return M diff --git a/lua/nvim_lsp/util.lua b/lua/nvim_lsp/util.lua index 73d8e6cf..02061976 100644 --- a/lua/nvim_lsp/util.lua +++ b/lua/nvim_lsp/util.lua @@ -208,7 +208,7 @@ end)() -- Returns a function(root_dir), which, when called with a root_dir it hasn't -- seen before, will call make_config(root_dir) and start a new client. -function M.server_per_root_dir_manager(make_config) +function M.server_per_root_dir_manager(_make_config) local clients = {} local manager = {} @@ -218,8 +218,7 @@ function M.server_per_root_dir_manager(make_config) -- Check if we have a client alredy or start and store it. local client_id = clients[root_dir] if not client_id then - local new_config = make_config(root_dir) - new_config.root_dir = root_dir + local new_config = _make_config(root_dir) new_config.on_exit = M.add_hook_before(new_config.on_exit, function() clients[root_dir] = nil end) |
