[mini.pick] custom picker to pick register
entries
#1740
-
Contributing guidelines
Module(s)mini.pick QuestionI saw this example in the help file: -- Adding custom picker to pick `register` entries
MiniPick.registry.registry = function()
local items = vim.tbl_keys(MiniPick.registry)
table.sort(items)
local source = {items = items, name = 'Registry', choose = function() end}
local chosen_picker_name = MiniPick.start({ source = source })
if chosen_picker_name == nil then return end
return MiniPick.registry[chosen_picker_name]()
end I'm wondering why it wasn't just written like this: MiniPick.registry.registry = function()
local items = vim.tbl_keys(MiniPick.registry)
table.sort(items)
MiniPick.start({
source = {
items = items,
name = "Registry",
choose = function(item)
if item == nil then return end
MiniPick.registry[item]()
end,
},
})
end |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
I don't think there was any reasonably substantial reason here. Probably a combination of "fit in as few lines as possible while exceeding maximum width of 78" and "showcase that |
Beta Was this translation helpful? Give feedback.
-
Thank you for the explanation! The design of mini is always simple and elegant—mini.pick proves it once again. I really like this module. |
Beta Was this translation helpful? Give feedback.
I don't think there was any reasonably substantial reason here. Probably a combination of "fit in as few lines as possible while exceeding maximum width of 78" and "showcase that
start()
is non-blocking but waits for return value which can be used later".