aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--runtime/doc/lsp.txt12
-rw-r--r--runtime/doc/news.txt6
-rw-r--r--runtime/lua/vim/lsp.lua16
3 files changed, 20 insertions, 14 deletions
diff --git a/runtime/doc/lsp.txt b/runtime/doc/lsp.txt
index 228bbafdd2..8b822daf9e 100644
--- a/runtime/doc/lsp.txt
+++ b/runtime/doc/lsp.txt
@@ -74,12 +74,8 @@ configurations, in increasing priority, from the following:
1. Configuration defined for the `'*'` name.
-2. Configuration from the result of sourcing all `lsp/<name>.lua` files
- in 'runtimepath' for a server of name `name`.
-
- Note: because of this, calls to |vim.lsp.config()| in `lsp/*.lua` are
- treated independently to other calls. This ensures configurations
- defined in `lsp/*.lua` have a lower priority.
+2. Configuration from the result of merging all tables returned by
+ `lsp/<name>.lua` files in 'runtimepath' for a server of name `name`.
3. Configurations defined anywhere else.
@@ -102,11 +98,11 @@ Given: >lua
})
-- Defined in ../lsp/clangd.lua
- vim.lsp.config('clangd', {
+ return {
cmd = { 'clangd' },
root_markers = { '.clangd', 'compile_commands.json' },
filetypes = { 'c', 'cpp' },
- })
+ }
-- Defined in init.lua
vim.lsp.config('clangd', {
diff --git a/runtime/doc/news.txt b/runtime/doc/news.txt
index 011970f5eb..eb04702ec2 100644
--- a/runtime/doc/news.txt
+++ b/runtime/doc/news.txt
@@ -22,6 +22,12 @@ EXPERIMENTS
• Removed `vim.loader.disable()`. Use `vim.loader.enable(false)` instead.
+LSP
+
+• `lsp/` runtimepath files should return a table instead of calling
+ |vim.lsp.config()| (or assigning to `vim.lsp.config`). See |lsp-config|
+
+
OPTIONS
• 'jumpoptions' flag "unload" has been renamed to "clean".
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 {}
)