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:
Jeremy Fleischman
2025-05-03 10:25:58 -07:00
committed by GitHub
parent 2e35161fa1
commit 03d378fda6
4 changed files with 41 additions and 0 deletions

View File

@@ -635,6 +635,14 @@ function lsp.enable(name, enable)
end
end
--- Checks if the given LSP config is enabled (globally, not per-buffer).
---
--- @param name string Config name
--- @return boolean
function lsp.is_enabled(name)
return lsp._enabled_configs[name] ~= nil
end
--- @class vim.lsp.start.Opts
--- @inlinedoc
---