diff options
| author | Hirokazu Hata <h.hata.ai.t@gmail.com> | 2020-06-09 13:53:34 +0900 |
|---|---|---|
| committer | Hirokazu Hata <h.hata.ai.t@gmail.com> | 2020-06-09 13:53:34 +0900 |
| commit | 24e19f074c093de99f1f1a75315238962f7df72b (patch) | |
| tree | f3c94beb747a4694967e6021dd097cfbe2f782de /lua/nvim_lsp/configs.lua | |
| parent | Merge pull request #269 from h-michael/lint (diff) | |
| download | nvim-lspconfig-24e19f074c093de99f1f1a75315238962f7df72b.tar nvim-lspconfig-24e19f074c093de99f1f1a75315238962f7df72b.tar.gz nvim-lspconfig-24e19f074c093de99f1f1a75315238962f7df72b.tar.bz2 nvim-lspconfig-24e19f074c093de99f1f1a75315238962f7df72b.tar.lz nvim-lspconfig-24e19f074c093de99f1f1a75315238962f7df72b.tar.xz nvim-lspconfig-24e19f074c093de99f1f1a75315238962f7df72b.tar.zst nvim-lspconfig-24e19f074c093de99f1f1a75315238962f7df72b.zip | |
fix the problem that commads cannot be registered in custom setup
resolve: https://github.com/neovim/nvim-lsp/issues/264
Diffstat (limited to 'lua/nvim_lsp/configs.lua')
| -rw-r--r-- | lua/nvim_lsp/configs.lua | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/lua/nvim_lsp/configs.lua b/lua/nvim_lsp/configs.lua index a70efdb5..6334be4b 100644 --- a/lua/nvim_lsp/configs.lua +++ b/lua/nvim_lsp/configs.lua @@ -19,6 +19,8 @@ function configs.__newindex(t, config_name, config_def) ['command.fn'] = {v[1], 'f'}; } end + else + config_def.commands = {} end local M = {} @@ -73,7 +75,17 @@ 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_extend("keep", config, default_config) local trigger @@ -171,12 +183,17 @@ function configs.__newindex(t, config_name, config_def) if client.config._on_attach then client.config._on_attach(client) end - if config_def.commands then + if client.config.commands and not vim.tbl_isempty(client.config.commands) then + M.commands = util.tbl_deep_extend("force", M.commands, client.config.commands) + end + if not M.commands_created and not vim.tbl_isempty(M.commands) then -- Create the module commands util.create_module_commands(config_name, M.commands) + M.commands_created = true end end + M.commands_created = false M.commands = config_def.commands M.name = config_name M.document_config = config_def |
