Is there any way to remap enter in fzf?
#2431
-
|
Is there any way to do something like this? {
'ibhagwan/fzf-lua',
opts = {
keymap = {
fzf = {
['enter'] = 'select-all+accept',
['ctrl-a'] = 'select-all+accept',
},
},
},
}My end goal is to make it such that when I press actions = {
['default'] = function(selected, opts)
opts.copen = false
actions.file_sel_to_qf(selected, opts)
actions.file_edit({ selected[1] }, opts)
end
},My question then is, can I achieve what |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments
-
|
After a quick dive into the source code, it seems that |
Beta Was this translation helpful? Give feedback.
-
|
FWIW, this hack accomplishes what I aimed to do, closing because it seems that at the moment there is no properly exposed API to do this. diff --git a/lua/fzf-lua/core.lua b/lua/fzf-lua/core.lua
index 0ebfa23..9e2dedd 100644
--- a/lua/fzf-lua/core.lua
+++ b/lua/fzf-lua/core.lua
@@ -595,6 +595,9 @@ M.create_fzf_binds = function(opts)
action = action:gsub("accept%s-$", "print(enter)+accept")
end
local bind = string.format("%s:%s", key, action)
+ if key == "enter" then
+ bind = string.format("%s:select-all+%s", key, action)
+ end
-- Separate "transform|execute|execute-silent" binds to their own `--bind` argument, this
-- way we can use `transform:...` and not be forced to use brackets, i.e. `transform(...)`
-- this enables us to use brackets in the inner actions, e.g. "zero:transform:rebind(...)" |
Beta Was this translation helpful? Give feedback.
-
|
You don’t need the hack, define enter in the actions map and add a prefix to it: actions = {
["enter"] = { fn = FzfLua.actions.file_edit, prefix = "select-all" }
}In your case: actions = {
['enter'] = {
fn = function(selected, opts)
opts.copen = false
actions.file_sel_to_qf(selected, opts)
actions.file_edit({ selected[1] }, opts)
end,
prefix = "select-all",
}
}, |
Beta Was this translation helpful? Give feedback.
-
Enter isn’t “reserved”, it’s mapped as the default action which you can reconfigure (as I posted above), the RPC calls you’re seeing are the “hide” profile callbacks so that you can resume the process from where you left so that enter won’t terminate the fzf process. If you configure a different profile that doesn’t contain the “hide” profile (default is border-fused+hide) you’ll see a different configuration without the execute-silent callbacks, instead you’ll see |
Beta Was this translation helpful? Give feedback.
-
|
Thanks for the help! This works out perfectly for my use case. |
Beta Was this translation helpful? Give feedback.
You don’t need the hack, define enter in the actions map and add a prefix to it:
In your case: