ESC keymap to go back to builtin #1123
Replies: 5 comments 9 replies
-
You can add an action to global defaults that sets esc as builtin: require("fzf-lua").setup({
defaults = {
actions = { ["esc"] = function() require("fzf-lua").builtin() end }
}
}) |
Beta Was this translation helpful? Give feedback.
-
I came up with the following code because there was a collateral issue with the code provided, that forbids the user to close fzf completely. The following code works fine except for the fact that one looses the custom initialization set. Is there a way I could achieve that without loosing my initialization? M.back_to_builtin = function()
--defaults = {
-- actions = { ["esc"] = function() require("fzf-lua").builtin() end }
--},
if not M.comes_from_builtin then
require("fzf-lua").setup({
defaults = {
actions = { ["esc"] = M.back_to_builtin }
}
})
else
require("fzf-lua").setup({
defaults = {
actions = { ["esc"] = actions.dummy_abort }
}
})
end
M.comes_from_builtin = not M.comes_from_builtin
require("fzf-lua").builtin()
end |
Beta Was this translation helpful? Give feedback.
-
I didn’t have this issue as I’m using vim.api.nvim_create_autocmd("FileType", {
pattern = "fzf",
callback = function(e)
vim.keymap.set("t", "<C-c>", "<C-c>", { buffer = e.buf, silent = true })
end,
})
Change the signature to: M.back_to_builtin = function(_, opts) And call the function with passing the original opts: require("fzf-lua").builtin(opts) |
Beta Was this translation helpful? Give feedback.
-
This would be a better soltution, add this to your original require("fzf-lua").setup({
defaults = {
actions = {
["esc"] = function(_, opts)
-- builtin doesn't fill the `__INFO` variable
if opts.__INFO then
require("fzf-lua").builtin()
end
end,
},
},
-- rest of your setup options
}) |
Beta Was this translation helpful? Give feedback.
-
I get the following message: Then followed with the previous stack trace I sent. .../.config/nvim/lua/plugins/fzf-lua.lua:62: attempt to call a nil value
stack traceback:
^.../.local/share/nvim/lazy/fzf-lua/lua/fzf-lua/core.lua:222: in function <....local/share/nvim/lazy/fzf-lua/lua/fzf-lua/core.lua:216>
^I~/.config/nvim/lua/plugins/fzf-lua.lua:62: in function 'action'
^I.../.local/share/nvim/lazy/fzf-lua/lua/fzf-lua/actions.lua:72: in function 'act'
^I.../.local/share/nvim/lazy/fzf-lua/lua/fzf-lua/core.lua:137: in function 'fn_selected'
^I.../.local/share/nvim/lazy/fzf-lua/lua/fzf-lua/core.lua:215: in function <....local/share/nvim/lazy/fzf-lua/lua/fzf-lua/core.lua:214>
^I[C]: in function 'xpcall'
^I.../.local/share/nvim/lazy/fzf-lua/lua/fzf-lua/core.lua:214: in function <...local/share/nvim/lazy/fzf-lua/lua/fzf-lua/core.lua:208> |
Beta Was this translation helpful? Give feedback.
-
Is there a way one can have a keymap to eg. ESC key that would navigate back to previous fzf-lua window?
The use case would be such that user:
Beta Was this translation helpful? Give feedback.
All reactions