aboutsummaryrefslogtreecommitdiffstats
path: root/lua/lspconfig/configs.lua
diff options
context:
space:
mode:
authorRaphael <glepnir@neovim.pro>2022-08-26 21:25:39 +0800
committerGitHub <noreply@github.com>2022-08-26 21:25:39 +0800
commitb89530f9f8783f19a172ed3a94fca2ba993c653b (patch)
tree2a9055c08a510645684ea521e9c7142f41fb89dd /lua/lspconfig/configs.lua
parentdocs: update server_configurations.md (diff)
downloadnvim-lspconfig-b89530f9f8783f19a172ed3a94fca2ba993c653b.tar
nvim-lspconfig-b89530f9f8783f19a172ed3a94fca2ba993c653b.tar.gz
nvim-lspconfig-b89530f9f8783f19a172ed3a94fca2ba993c653b.tar.bz2
nvim-lspconfig-b89530f9f8783f19a172ed3a94fca2ba993c653b.tar.lz
nvim-lspconfig-b89530f9f8783f19a172ed3a94fca2ba993c653b.tar.xz
nvim-lspconfig-b89530f9f8783f19a172ed3a94fca2ba993c653b.tar.zst
nvim-lspconfig-b89530f9f8783f19a172ed3a94fca2ba993c653b.zip
Revert "fix: remove the config.commands (#2092)" (#2093)
This reverts commit 99e0dc9937b124dee7d8107185e804ff96466279.
Diffstat (limited to 'lua/lspconfig/configs.lua')
-rw-r--r--lua/lspconfig/configs.lua27
1 files changed, 27 insertions, 0 deletions
diff --git a/lua/lspconfig/configs.lua b/lua/lspconfig/configs.lua
index 4bfe3f5c..a0129776 100644
--- a/lua/lspconfig/configs.lua
+++ b/lua/lspconfig/configs.lua
@@ -10,7 +10,18 @@ function configs.__newindex(t, config_name, config_def)
default_config = { config_def.default_config, 't' },
on_new_config = { config_def.on_new_config, 'f', true },
on_attach = { config_def.on_attach, 'f', true },
+ commands = { config_def.commands, 't', true },
}
+ if config_def.commands then
+ for k, v in pairs(config_def.commands) do
+ validate {
+ ['command.name'] = { k, 's' },
+ ['command.fn'] = { v[1], 'f' },
+ }
+ end
+ else
+ config_def.commands = {}
+ end
local M = {}
@@ -28,7 +39,16 @@ function configs.__newindex(t, config_name, config_def)
filetypes = { config.filetype, 't', true },
on_new_config = { config.on_new_config, 'f', true },
on_attach = { config.on_attach, 'f', true },
+ commands = { config.commands, 't', true },
}
+ if config.commands then
+ for k, v in pairs(config.commands) do
+ validate {
+ ['command.name'] = { k, 's' },
+ ['command.fn'] = { v[1], 'f' },
+ }
+ end
+ end
config = tbl_deep_extend('keep', config, default_config)
@@ -267,8 +287,15 @@ function configs.__newindex(t, config_name, config_def)
if client.config._on_attach then
client.config._on_attach(client, bufnr)
end
+ if client.config.commands and not vim.tbl_isempty(client.config.commands) then
+ M.commands = vim.tbl_deep_extend('force', M.commands, client.config.commands)
+ end
+ if not M.commands_created and not vim.tbl_isempty(M.commands) then
+ util.create_module_commands(config_name, M.commands)
+ end
end
+ M.commands = config_def.commands
M.name = config_name
M.document_config = config_def