commit 0a7e4e9e5f28f3b6b3c83040430d0a36fcd71fad
parent bc69f2723737cfe8916c117483ce32f48ff83544
Author: Andrew Braxton <42975660+andrewbraxton@users.noreply.github.com>
Date: Wed, 15 Jan 2025 04:58:36 -0500
fix(lsp): vim.lsp.enable(...,false) does not disable #32002
Problem:
Per the documentation, passing `false` as the `enable` parameter of
`vim.lsp.enable()` should disable the given LSP(s), but it does not work
due to a logic error.
Specifically, `enable == false and nil or {}` will always evaluate to
`{}` because `nil` is falsy.
Solution:
Correct the conditional statement.
Diffstat:
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/runtime/lua/vim/lsp.lua b/runtime/lua/vim/lsp.lua
@@ -546,7 +546,7 @@ function lsp.enable(name, enable)
if nm == '*' then
error('Invalid name')
end
- lsp._enabled_configs[nm] = enable == false and nil or {}
+ lsp._enabled_configs[nm] = enable ~= false and {} or nil
end
if not next(lsp._enabled_configs) then