mirror of
https://github.com/neovim/neovim.git
synced 2025-09-30 06:58:35 +00:00
fix(lsp): better handling of "*" configs
Problem:
If a config name contains "*" it causes rtp discovery of `lsp/` to
consider the `*` as a wildcard and could lead to strange and unintended
behaviour. For example, accessing the `'*'` config from a `lsp/` file
would cause an infinite loop.
Solution:
- Explicitly disallow a config name from containing wildcards, with the
exception of `'*'`.
- When Resolving `'*'` config, skip the rtp step.
(cherry picked from commit 2ee896201c
)
This commit is contained in:

committed by
Lewis Russell

parent
a4b6705e87
commit
1e8e74dbff
@@ -6414,5 +6414,36 @@ describe('LSP', function()
|
||||
filetypes = true,
|
||||
}, 'cannot start foo due to config error: .* filetypes: expected table, got boolean')
|
||||
end)
|
||||
|
||||
it('does not allow wildcards in config name', function()
|
||||
local err =
|
||||
'.../lsp.lua:0: name: expected non%-wildcard string, got foo%*%. Info: LSP config name cannot contain wildcard %("%*"%)'
|
||||
|
||||
matches(
|
||||
err,
|
||||
pcall_err(exec_lua, function()
|
||||
local _ = vim.lsp.config['foo*']
|
||||
end)
|
||||
)
|
||||
|
||||
matches(
|
||||
err,
|
||||
pcall_err(exec_lua, function()
|
||||
vim.lsp.config['foo*'] = {}
|
||||
end)
|
||||
)
|
||||
|
||||
matches(
|
||||
err,
|
||||
pcall_err(exec_lua, function()
|
||||
vim.lsp.config('foo*', {})
|
||||
end)
|
||||
)
|
||||
|
||||
-- Exception for '*'
|
||||
pcall(exec_lua, function()
|
||||
vim.lsp.config('*', {})
|
||||
end)
|
||||
end)
|
||||
end)
|
||||
end)
|
||||
|
Reference in New Issue
Block a user