fix(toggle): set/get raw values for option toggles. See #2390

This commit is contained in:
Folke Lemaitre 2025-11-05 08:02:27 +01:00
parent 9a04605664
commit 41da728f02
No known key found for this signature in database
GPG key ID: 9B52594D560070AB

View file

@ -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