feat(toggle): use vim.diagnostic.is_disabled when available (#2217)

* feat(toggle-diagnostics): change logic based on `vim.diagnostic.is_disabled`

After discussion in #2215, I thought maybe it would be beneficial if we
could change the logic of the `toggle-diagnostics` function based on if
the user has disabled diagnostics in his own configuration.

* feat(toggle-diagnostics): revert to `enable` instead of `status`

* fix(toggle): use vim.diagnostics enabled state when possible

---------

Co-authored-by: Folke Lemaitre <folke.lemaitre@gmail.com>
This commit is contained in:
Iordanis Petkakis 2024-01-21 21:41:11 +02:00 committed by GitHub
parent a43d8cf358
commit 93342f15ba
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -43,7 +43,13 @@ end
local enabled = true
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
vim.diagnostic.enable()
Util.info("Enabled diagnostics", { title = "Diagnostics" })