From 7e354ab795bb81ef9145359095857d073346e932 Mon Sep 17 00:00:00 2001 From: Iordanis Petkakis <12776461+dpetka2001@users.noreply.github.com> Date: Sat, 26 Oct 2024 21:24:59 +0300 Subject: [PATCH] feat(toggle): add `silent` field to toggle to customize behavior of notifications --- lua/lazyvim/util/toggle.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lua/lazyvim/util/toggle.lua b/lua/lazyvim/util/toggle.lua index d693dd9d..4f7440f6 100644 --- a/lua/lazyvim/util/toggle.lua +++ b/lua/lazyvim/util/toggle.lua @@ -8,6 +8,7 @@ local M = {} ---@field color_disabled? string ---@field get fun():boolean ---@field set fun(state:boolean) +---@field silent? boolean ---@class lazyvim.Toggle.wrap: lazyvim.Toggle ---@operator call:boolean @@ -18,9 +19,9 @@ function M.wrap(toggle) __call = function() toggle.set(not toggle.get()) local state = toggle.get() - if state then + if state and not toggle.silent then LazyVim.info("Enabled " .. toggle.name, { title = toggle.name }) - else + elseif not state and not toggle.silent then LazyVim.warn("Disabled " .. toggle.name, { title = toggle.name }) end return state