mirror of
https://github.com/neovim/neovim.git
synced 2025-12-16 03:15:39 +00:00
feat(lsp): vim.lsp.is_enabled() #33703
Problem: No way to check if a LSP config is enabled without causing it to resolve. E.g. `vim.lsp.config['…'] ~= nil` will resolve the config, which could be an unwanted and somewhat expensive side-effect. Solution: Introduce `vim.lsp.is_enabled()`.
This commit is contained in:
committed by
GitHub
parent
2e35161fa1
commit
03d378fda6
@@ -6680,4 +6680,26 @@ describe('LSP', function()
|
||||
markers_resolve_to({ 'foo', { 'bar', 'baz' }, 'marker_d' }, dir_b)
|
||||
end)
|
||||
end)
|
||||
|
||||
describe('vim.lsp.is_enabled()', function()
|
||||
it('works', function()
|
||||
exec_lua(function()
|
||||
vim.lsp.config('foo', {
|
||||
cmd = { 'foo' },
|
||||
root_markers = { '.foorc' },
|
||||
})
|
||||
end)
|
||||
|
||||
-- LSP config defaults to disabled.
|
||||
eq(false, exec_lua([[return vim.lsp.is_enabled('foo')]]))
|
||||
|
||||
-- Confirm we can enable it.
|
||||
exec_lua([[vim.lsp.enable('foo')]])
|
||||
eq(true, exec_lua([[return vim.lsp.is_enabled('foo')]]))
|
||||
|
||||
-- And finally, disable it again.
|
||||
exec_lua([[vim.lsp.enable('foo', false)]])
|
||||
eq(false, exec_lua([[return vim.lsp.is_enabled('foo')]]))
|
||||
end)
|
||||
end)
|
||||
end)
|
||||
|
||||
Reference in New Issue
Block a user