-
I was trying to update the user input when user press I thought the I tried the solution from here: https://github.com/ibhagwan/fzf-lua/wiki/Advanced#action-resume , but it doesn't work:( require('fzf-lua').fzf_exec(CMD_LIST, {
prompt = " Project commands ('ctrl+d' to delete item) ",
winopts = {
width = 0.50,
height = 0.40,
},
actions = {
--
-- `tab` to use selected item as user intput
--
["tab"] = {
fn = function(selected, opts)
print(string.format(
">>> user input: %s, type: %s",
vim.inspect(opts.last_query),
type(opts.last_query)
))
if #selected == 0 then return end
opts.last_query = selected[1]
-- Confirmed it has been updated!!!
print(string.format(
">>> user input: %s, type: %s",
vim.inspect(opts.last_query),
type(opts.last_query)
))
end,
reload = true
-- But the user input UI doesn't get updated
},
-- ["tab"] = {
-- function(selected, opts)
-- print(string.format(
-- ">>> user input: %s, type: %s",
-- vim.inspect(opts.last_query),
-- type(opts.last_query)
-- ))
--
-- if #selected == 0 then return end
--
-- opts.last_query = selected[1]
--
-- -- Confirmed it has been updated!!!
-- print(string.format(
-- ">>> user input: %s, type: %s",
-- vim.inspect(opts.last_query),
-- type(opts.last_query)
-- ))
-- end,
-- require'fzf-lua'.actions.resume
--
-- -- But the user input UI doesn't get updated
-- }
},
}) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
The answer is simple but requires a bit of know how of fzf and fzf-lua, the last arg of
require 'fzf-lua'.fzf_exec("ls", {
keymap = {
fzf = {
tab = "transform:" .. FzfLua.shell.stringify_data(function(args)
local q = args[1]
return string.format("change-query(%s)", q)
end, {}, "{}")
}
}
}) |
Beta Was this translation helpful? Give feedback.
While I could’ve offered to you this rather simple solution I preferred to show you what’s possible in case you’d decide on a more complex transformation which required lua code.
Your understanding is accurate, the code is simpler than you think, add
debug=true
and you’ll see the fzf command line arguments generated by fzf-lua,stringify_data
returns a shell command with the field…