From 0a7e4e9e5f28f3b6b3c83040430d0a36fcd71fad Mon Sep 17 00:00:00 2001 From: Andrew Braxton <42975660+andrewbraxton@users.noreply.github.com> Date: Wed, 15 Jan 2025 04:58:36 -0500 Subject: [PATCH] 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. --- runtime/lua/vim/lsp.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/lua/vim/lsp.lua b/runtime/lua/vim/lsp.lua index 7812f31db1..147d29d6be 100644 --- 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