fix(toggle-diagnostics): correctly set initial state

With the previous implementation of `toggle-diagnostics` in #3cbfeab, if
the user had disabled diagnostics, the first toggle call (using the
keymap) would again disable diagnostics and the next one would enable
them.
This commit is contained in:
Iordanis Petkakis 2024-01-27 01:07:29 +02:00
parent a50f92f755
commit 30a950e77f

View file

@ -41,13 +41,15 @@ function M.number()
end
end
local enabled = true
local enabled
-- if this Neovim version supports checking if diagnostics are enabled
-- then use that for the current state
if vim.diagnostic.is_disabled then
enabled = not vim.diagnostic.is_disabled()
else
enabled = true
end
function M.diagnostics()
-- if this Neovim version supports checking if diagnostics are enabled
-- then use that for the current state
if vim.diagnostic.is_disabled then
enabled = not vim.diagnostic.is_disabled()
end
enabled = not enabled
if enabled then