mirror of
https://github.com/LazyVim/LazyVim.git
synced 2026-07-25 14:01:06 +00:00
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:
parent
a50f92f755
commit
30a950e77f
1 changed files with 8 additions and 6 deletions
|
|
@ -41,13 +41,15 @@ function M.number()
|
||||||
end
|
end
|
||||||
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()
|
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
|
enabled = not enabled
|
||||||
|
|
||||||
if enabled then
|
if enabled then
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue