@@ -658,32 +658,29 @@ function M.is_executable(absolute_path)
658
658
end
659
659
end
660
660
661
- --- List of all option info/values
662
- --- @param opts vim.api.keyset.option passed directly to vim.api.nvim_get_option_info2 and vim.api.nvim_get_option_value
663
- --- @param was_set boolean filter was_set
664
- --- @return { info : vim.api.keyset.get_option_info , val : any } []
665
- function M .enumerate_options (opts , was_set )
666
- local res = {}
667
-
668
- local infos = vim .tbl_filter (function (info )
669
- if opts .buf and info .scope ~= " buf" then
670
- return false
671
- elseif opts .win and info .scope ~= " win" then
672
- return false
661
+ --- @class UtilEnumerateOptionsOpts
662
+ --- @field keyset_opts vim.api.keyset.option
663
+ --- @field was_set boolean ? as per vim.api.keyset.get_option_info
664
+
665
+ --- Option name/values
666
+ --- @param opts UtilEnumerateOptionsOpts
667
+ --- @return table<string , any>
668
+ function M .enumerate_options (opts )
669
+ -- enumerate all options, limiting buf and win scopes
670
+ return vim .tbl_map (function (info )
671
+ if opts .keyset_opts .buf and info .scope ~= " buf" then
672
+ return nil
673
+ elseif opts .keyset_opts .win and info .scope ~= " win" then
674
+ return nil
673
675
else
674
- return true
676
+ -- optional, lazy was_set check
677
+ if not opts .was_set or vim .api .nvim_get_option_info2 (info .name , opts .keyset_opts ).was_set then
678
+ return vim .api .nvim_get_option_value (info .name , opts .keyset_opts )
679
+ else
680
+ return nil
681
+ end
675
682
end
676
683
end , vim .api .nvim_get_all_options_info ())
677
-
678
- for _ , info in vim .spairs (infos ) do
679
- local _ , info2 = pcall (vim .api .nvim_get_option_info2 , info .name , opts )
680
- if not was_set or info2 .was_set then
681
- local val = pcall (vim .api .nvim_get_option_value , info .name , opts )
682
- table.insert (res , { info = info2 , val = val })
683
- end
684
- end
685
-
686
- return res
687
684
end
688
685
689
686
return M
0 commit comments