mirror of
https://github.com/zoriya/telescope.nvim.git
synced 2025-12-06 06:46:10 +00:00
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:
@@ -656,7 +656,11 @@ end
|
|||||||
internal.vim_options = function(opts)
|
internal.vim_options = function(opts)
|
||||||
local res = {}
|
local res = {}
|
||||||
for _, v in pairs(vim.api.nvim_get_all_options_info()) do
|
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
|
end
|
||||||
table.sort(res, function(left, right)
|
table.sort(res, function(left, right)
|
||||||
return left.name < right.name
|
return left.name < right.name
|
||||||
@@ -684,7 +688,8 @@ internal.vim_options = function(opts)
|
|||||||
end
|
end
|
||||||
|
|
||||||
vim.api.nvim_feedkeys(
|
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",
|
"m",
|
||||||
true
|
true
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1003,21 +1003,13 @@ function make_entry.gen_from_vimoptions(opts)
|
|||||||
display = make_display,
|
display = make_display,
|
||||||
value = {
|
value = {
|
||||||
name = o.name,
|
name = o.name,
|
||||||
value = o.default,
|
value = o.value,
|
||||||
type = o.type,
|
type = o.type,
|
||||||
scope = o.scope,
|
scope = o.scope,
|
||||||
},
|
},
|
||||||
ordinal = string.format("%s %s %s", o.name, o.type, o.scope),
|
ordinal = string.format("%s %s %s %s", o.name, o.type, o.scope, utils.display_termcodes(tostring(o.value))),
|
||||||
}
|
}
|
||||||
|
|
||||||
local ok, value = pcall(vim.api.nvim_get_option, o.name)
|
|
||||||
if ok then
|
|
||||||
entry.value.value = value
|
|
||||||
entry.ordinal = entry.ordinal .. " " .. utils.display_termcodes(tostring(value))
|
|
||||||
else
|
|
||||||
entry.ordinal = entry.ordinal .. " " .. utils.display_termcodes(tostring(o.default))
|
|
||||||
end
|
|
||||||
|
|
||||||
return make_entry.set_default_entry_mt(entry, opts)
|
return make_entry.set_default_entry_mt(entry, opts)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user