aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Lingelbach <m.j.lbach@gmail.com>2021-07-19 14:24:38 -0700
committerGitHub <noreply@github.com>2021-07-19 14:24:38 -0700
commit4d2239d258388cb69fa656a35ae16e34267d92c8 (patch)
tree8f263d23889dc583c8a36bbc19d6f9e627f24f54
parent[docgen] Update CONFIG.md (diff)
parentfeat: added global on_setup hook (diff)
downloadnvim-lspconfig-4d2239d258388cb69fa656a35ae16e34267d92c8.tar
nvim-lspconfig-4d2239d258388cb69fa656a35ae16e34267d92c8.tar.gz
nvim-lspconfig-4d2239d258388cb69fa656a35ae16e34267d92c8.tar.bz2
nvim-lspconfig-4d2239d258388cb69fa656a35ae16e34267d92c8.tar.lz
nvim-lspconfig-4d2239d258388cb69fa656a35ae16e34267d92c8.tar.xz
nvim-lspconfig-4d2239d258388cb69fa656a35ae16e34267d92c8.tar.zst
nvim-lspconfig-4d2239d258388cb69fa656a35ae16e34267d92c8.zip
Merge pull request #1072 from folke/global_config
feat: added global_config hooks
-rw-r--r--lua/lspconfig/configs.lua6
-rw-r--r--lua/lspconfig/util.lua7
2 files changed, 12 insertions, 1 deletions
diff --git a/lua/lspconfig/configs.lua b/lua/lspconfig/configs.lua
index ee434028..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, ',')
@@ -84,7 +88,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
diff --git a/lua/lspconfig/util.lua b/lua/lspconfig/util.lua
index c18f3072..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' },
@@ -222,6 +225,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(