From 3cbfeab71837e060ccbdd880812884ddcb4637c0 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Sun, 21 Jan 2024 20:40:11 +0100 Subject: [PATCH] fix(toggle): use vim.diagnostics enabled state when possible --- lua/lazyvim/util/toggle.lua | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lua/lazyvim/util/toggle.lua b/lua/lazyvim/util/toggle.lua index c8a89745..409556d1 100644 --- a/lua/lazyvim/util/toggle.lua +++ b/lua/lazyvim/util/toggle.lua @@ -41,9 +41,15 @@ function M.number() end end -local enabled = not vim.diagnostic.is_disabled() +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" })