fix(builtin.vim_options): fix getting current option values (#3258)

* fix(builtin.vim_options): fix getting current option values

* fix: get options properly and skip invalid options

* fix: move option getting out of entry maker

* fix: fix toggle of booleans

* style: fix formatting
This commit is contained in:
sid-6581
2024-09-22 20:58:34 -05:00
committed by GitHub
parent 175178e388
commit 2ffcfc0d93
2 changed files with 9 additions and 12 deletions

View File

@@ -656,7 +656,11 @@ end
internal.vim_options = function(opts)
local res = {}
for _, v in pairs(vim.api.nvim_get_all_options_info()) do
table.insert(res, v)
local ok, value = pcall(vim.api.nvim_get_option_value, v.name, {})
if ok then
v.value = value
table.insert(res, v)
end
end
table.sort(res, function(left, right)
return left.name < right.name
@@ -684,7 +688,8 @@ internal.vim_options = function(opts)
end
vim.api.nvim_feedkeys(
string.format("%s:set %s=%s", esc, selection.value.name, selection.value.value),
selection.value.type == "boolean" and string.format("%s:set %s!", esc, selection.value.name)
or string.format("%s:set %s=%s", esc, selection.value.name, selection.value.value),
"m",
true
)