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.
This commit is contained in:
Andrew Braxton
2025-01-15 04:58:36 -05:00
committed by GitHub
parent bc69f27237
commit 0a7e4e9e5f

View File

@ -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