feat(picker.config): added opts.config which can be a function that can change the resolved options

This commit is contained in:
Folke Lemaitre 2025-01-30 10:40:10 +01:00
parent 69c013e1b2
commit b37f368a81
2 changed files with 6 additions and 0 deletions

View file

@ -98,6 +98,7 @@ local M = {}
---@field on_show? fun(picker:snacks.Picker) called when the picker is shown
---@field jump? snacks.picker.jump.Config|{}
--- Other
---@field config? fun(opts:snacks.picker.Config):snacks.picker.Config? custom config function
---@field debug? snacks.picker.debug|{}
local defaults = {
prompt = "",

View file

@ -82,6 +82,11 @@ function M.get(opts)
elseif opts.cwd then
opts.cwd = vim.fs.normalize(vim.fn.fnamemodify(opts.cwd, ":p"))
end
for _, t in ipairs(todo) do
if t.config then
opts = t.config(opts) or opts
end
end
M.multi(opts)
return opts
end