feat(fzf_exec): easy API to run custom commands

main
bhagwan 2 years ago
parent 5f473263b9
commit b17cc7220a

@ -40,6 +40,7 @@ M.fzf_resume = function(opts)
end
M.fzf_wrap = function(opts, contents, fn_selected)
opts = opts or {}
return coroutine.wrap(function()
opts.fn_selected = opts.fn_selected or fn_selected
local selected = M.fzf(opts, contents)
@ -49,6 +50,14 @@ M.fzf_wrap = function(opts, contents, fn_selected)
end)
end
M.fzf_exec = function(contents, opts, fn_selected)
fn_selected = fn_selected or function(selected)
if not selected then return end
actions.act(opts and opts.actions or nil, selected)
end
return M.fzf_wrap(opts, contents, fn_selected)()
end
M.fzf = function(opts, contents)
-- normalize with globals if not already normalized
if not opts._normalized then

@ -156,6 +156,7 @@ M.dap_frames = require'fzf-lua.providers.dap'.frames
-- API shortcuts
M.fzf = require'fzf-lua.core'.fzf
M.fzf_wrap = require'fzf-lua.core'.fzf_wrap
M.fzf_exec = require'fzf-lua.core'.fzf_exec
M.raw_fzf = require'fzf-lua.fzf'.raw_fzf
-- exported modules
@ -175,6 +176,7 @@ M._excluded_meta = {
'setup',
'fzf',
'fzf_wrap',
'fzf_exec',
'raw_fzf',
'_excluded_meta',
'_excluded_metamap',

Loading…
Cancel
Save