From ddfba1c750036c8711375d650009898bf02b0ec5 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Mon, 19 Jul 2021 23:12:57 +0200 Subject: feat: added option to disable an lsp server from the config --- lua/lspconfig/util.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lua/lspconfig/util.lua b/lua/lspconfig/util.lua index c18f3072..d2925edf 100644 --- a/lua/lspconfig/util.lua +++ b/lua/lspconfig/util.lua @@ -222,6 +222,10 @@ function M.server_per_root_dir_manager(_make_config) local client_id = clients[root_dir] if not client_id then local new_config = _make_config(root_dir) + -- do nothing if the client is not enabled + if new_config.enabled == false then + return + end --TODO:mjlbach -- these prints only show up with nvim_error_writeln() if not new_config.cmd then print( -- cgit v1.2.3-70-g09d2 From 5830a3847886215a4787b86ca19800131c1e8c75 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Mon, 19 Jul 2021 23:22:05 +0200 Subject: fix: expose get_root_dir instead of config.root_dir --- lua/lspconfig/configs.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/lspconfig/configs.lua b/lua/lspconfig/configs.lua index ee434028..9027915e 100644 --- a/lua/lspconfig/configs.lua +++ b/lua/lspconfig/configs.lua @@ -84,7 +84,7 @@ function configs.__newindex(t, config_name, config_def) end -- Used by :LspInfo - M.get_root_dir = config.root_dir + M.get_root_dir = get_root_dir M.filetypes = config.filetypes M.handlers = config.handlers M.cmd = config.cmd -- cgit v1.2.3-70-g09d2 From 96b764ba7925cfafb8346cb5afd7b128e6f8bb8a Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Mon, 19 Jul 2021 23:22:12 +0200 Subject: feat: added global on_setup hook --- lua/lspconfig/configs.lua | 4 ++++ lua/lspconfig/util.lua | 3 +++ 2 files changed, 7 insertions(+) diff --git a/lua/lspconfig/configs.lua b/lua/lspconfig/configs.lua index 9027915e..78377eac 100644 --- a/lua/lspconfig/configs.lua +++ b/lua/lspconfig/configs.lua @@ -50,6 +50,10 @@ function configs.__newindex(t, config_name, config_def) config = tbl_extend('keep', config, default_config) + if util.on_setup then + pcall(util.on_setup, config) + end + local trigger if config.filetypes then trigger = 'FileType ' .. table.concat(config.filetypes, ',') diff --git a/lua/lspconfig/util.lua b/lua/lspconfig/util.lua index d2925edf..98cbc28d 100644 --- a/lua/lspconfig/util.lua +++ b/lua/lspconfig/util.lua @@ -15,6 +15,9 @@ M.default_config = { handlers = {}, } +-- global on_setup hook +M.on_setup = nil + function M.validate_bufnr(bufnr) validate { bufnr = { bufnr, 'n' }, -- cgit v1.2.3-70-g09d2