From 41da728f0280033c13aaa4e2820bd3e926790a28 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Wed, 5 Nov 2025 08:02:27 +0100 Subject: [PATCH] fix(toggle): set/get raw values for option toggles. See #2390 --- lua/snacks/toggle.lua | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/lua/snacks/toggle.lua b/lua/snacks/toggle.lua index a53f3be1..a0141838 100644 --- a/lua/snacks/toggle.lua +++ b/lua/snacks/toggle.lua @@ -159,17 +159,11 @@ function M.option(option, opts) id = option, name = option, get = function() - if opts.global then - return vim.opt[option]:get() == on - end - return vim.opt_local[option]:get() == on + return vim.api.nvim_get_option_value(option, { scope = opts.global and "global" or "local" }) == on end, set = function(state) - if opts.global then - vim.opt[option] = state and on or off - return - end - vim.opt_local[option] = state and on or off + local value = state and on or off + vim.api.nvim_set_option_value(option, value, { scope = opts.global and "global" or "local" }) end, }, opts) end