mirror of
https://github.com/LazyVim/LazyVim.git
synced 2025-06-21 16:39:06 +02:00
fix(toggle): diagnostics enable/disable. See #4205
This commit is contained in:
parent
c012f85959
commit
3dbace941e
1 changed files with 6 additions and 13 deletions
|
@ -127,30 +127,23 @@ M.number = M.wrap({
|
||||||
M.diagnostics = M.wrap({
|
M.diagnostics = M.wrap({
|
||||||
name = "Diagnostics",
|
name = "Diagnostics",
|
||||||
get = function()
|
get = function()
|
||||||
local enabled
|
local enabled = false
|
||||||
if vim.diagnostic.is_enabled then
|
if vim.diagnostic.is_enabled then
|
||||||
enabled = vim.diagnostic.is_enabled()
|
enabled = vim.diagnostic.is_enabled()
|
||||||
else
|
elseif vim.diagnostic.is_disabled then
|
||||||
enabled = not vim.diagnostic.is_disabled()
|
enabled = not vim.diagnostic.is_disabled()
|
||||||
end
|
end
|
||||||
return enabled
|
return enabled
|
||||||
end,
|
end,
|
||||||
set = function()
|
set = function(state)
|
||||||
local enabled
|
|
||||||
if vim.diagnostic.is_enabled then
|
|
||||||
enabled = vim.diagnostic.is_enabled()
|
|
||||||
else
|
|
||||||
enabled = not vim.diagnostic.is_disabled()
|
|
||||||
end
|
|
||||||
enabled = not enabled
|
|
||||||
if vim.fn.has("nvim-0.10") == 0 then
|
if vim.fn.has("nvim-0.10") == 0 then
|
||||||
if enabled then
|
if state then
|
||||||
pcall(vim.diagnostic.enable)
|
pcall(vim.diagnostic.enable)
|
||||||
else
|
else
|
||||||
vim.diagnostic.disable()
|
pcall(vim.diagnostic.disable)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
vim.diagnostic.enable(enabled)
|
vim.diagnostic.enable(state)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue