mirror of
https://github.com/folke/snacks.nvim
synced 2025-12-23 08:47:57 +00:00
fix(toggle): set/get raw values for option toggles. See #2390
This commit is contained in:
parent
9a04605664
commit
41da728f02
1 changed files with 3 additions and 9 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue