diff options
author | Gregory Anders <greg@gpanders.com> | 2024-12-21 08:27:27 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-12-21 08:27:27 -0600 |
commit | 130b5fd85f074ac5e40cb4b07c6c9dc6f91512bd (patch) | |
tree | ff3f22ad9316edb6ff26b4b9260b979aa333083f /runtime/lua/vim/lsp.lua | |
parent | 382eb878bcbfba3b11d9c2deb21928e5319b32ad (diff) | |
download | rneovim-130b5fd85f074ac5e40cb4b07c6c9dc6f91512bd.tar.gz rneovim-130b5fd85f074ac5e40cb4b07c6c9dc6f91512bd.tar.bz2 rneovim-130b5fd85f074ac5e40cb4b07c6c9dc6f91512bd.zip |
feat(lsp): return table from lsp/ files on runtimepath (#31663)
Problem: LSP configs on the runtimepath must have the same name as the
LSP server and must also explicitly set the name in vim.lsp.config. This
is redundant and creates a footgun where a user may accidentally use the
wrong name when assigning to the vim.lsp.config table.
Solution: Return a table from lsp/ runtimepath files instead
Diffstat (limited to 'runtime/lua/vim/lsp.lua')
-rw-r--r-- | runtime/lua/vim/lsp.lua | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/runtime/lua/vim/lsp.lua b/runtime/lua/vim/lsp.lua index 5a93da4298..19d0377585 100644 --- a/runtime/lua/vim/lsp.lua +++ b/runtime/lua/vim/lsp.lua @@ -450,16 +450,20 @@ function lsp._resolve_config(name) if not econfig.resolved_config then -- Resolve configs from lsp/*.lua -- Calls to vim.lsp.config in lsp/* have a lower precedence than calls from other sites. - local orig_configs = lsp.config._configs - lsp.config._configs = {} - pcall(vim.cmd.runtime, { ('lsp/%s.lua'):format(name), bang = true }) - local rtp_configs = lsp.config._configs - lsp.config._configs = orig_configs + local rtp_config = {} ---@type vim.lsp.Config + for _, v in ipairs(api.nvim_get_runtime_file(('lsp/%s.lua'):format(name), true)) do + local config = assert(loadfile(v))() ---@type any? + if type(config) == 'table' then + rtp_config = vim.tbl_deep_extend('force', rtp_config, config) + else + log.warn(string.format('%s does not return a table, ignoring', v)) + end + end local config = vim.tbl_deep_extend( 'force', lsp.config._configs['*'] or {}, - rtp_configs[name] or {}, + rtp_config, lsp.config._configs[name] or {} ) |