Bug: Switching buffers seems to be broken
Closed this issue · 3 comments
RTFM Checklist
- I have searched exisiting issues / discussions
- I have read the Wiki including the Advanced section
- I have read
man fzf
/ I am well versed in shell fzf
Operating system
Linux
Shell
zsh
Neovim version (nvim --version
)
NVIM v0.10.1
Fzf version (fzf --version
)
0.54.3 (Fedora)
Output of :lua print(os.getenv('FZF_DEFAULT_OPTS'))
--bind=ctrl-k:up,ctrl-j:down
Is the problem reproducible with mini.sh
?
- My issue is reproducible with
mini.sh
- My issue IS NOT reproducible with
mini.sh
- I have not tested with
mini.sh
(not relevant, requires LSP, Windows, etc)
Fzf-lua configuration
{
"ibhagwan/fzf-lua",
config = function()
local actions = require "fzf-lua.actions"
require("fzf-lua").setup({
"telescope",
winopts = {
backdrop = 100, -- Disable dark background
},
actions = {
files = {
["ctrl-x"] = actions.file_split,
["ctrl-v"] = actions.file_vsplit,
["ctrl-t"] = actions.file_tabedit,
["ctrl-q"] = actions.file_sel_to_qf,
},
buffers = {
["ctrl-x"] = actions.buf_split,
["ctrl-v"] = actions.buf_vsplit,
["ctrl-t"] = actions.buf_tabedit,
},
},
})
end,
},
Describe the bug / steps to reproduce
Hey and thanks for this awesome plugin which has become a daily driver for my work!
I used to be able to open the buffer view and then open the desired buffer either using <enter>
, <ctrl-x>
, <ctrl-v>
, and <ctrl-t>
(see the above config).
However for some reason this has stopped working now: The buffer
window pops up but pressing <enter>
or any other key only results in the window disappearing again without switching to the selected buffer.
Happy to debug this further if you point me in the right direction as I was unable to reproduce this with mini.sh
🤔.
I made changes so what recently, you only need actions.files
but you also need to define the enter action or inherit from the default binds (by adding true
in [1]
):
require("fzf-lua").setup({
"telescope",
winopts = {
backdrop = 100, -- Disable dark background
},
actions = {
files = {
-- Uncomment to inherit the defaults,
-- only if you do this you don’t need to define `enter`
--true,
["enter"] = actions.file_edit_or_qf,
["ctrl-x"] = actions.file_split,
["ctrl-v"] = actions.file_vsplit,
["ctrl-t"] = actions.file_tabedit,
["ctrl-q"] = actions.file_sel_to_qf,
},
},
})
end,
},
Thanks for the quick answer! I might have been unclear before, but my issue is that my keybindings for buffers stopped working. Apparently the hierarchy of where I defined the keybindings was wrong although this (accidentially) has worked in the past.
This fixes it:
winopts = {
backdrop = 100, -- Disable dark background
},
+ files = {
actions = {
- files = {
["ctrl-x"] = actions.file_split,
["ctrl-v"] = actions.file_vsplit,
["ctrl-t"] = actions.file_tabedit,
["ctrl-q"] = actions.file_sel_to_qf,
},
- buffers = {
+ },
+ buffers = {
+ actions = {
["ctrl-x"] = actions.buf_split,
["ctrl-v"] = actions.buf_vsplit,
["ctrl-t"] = actions.buf_tabedit,
Thanks for the quick answer! I might have been unclear before, but my issue is that my keybindings for buffers stopped working. Apparently the hierarchy of where I defined the keybindings was wrong although this (accidentially) has worked in the past.
This fixes it:
winopts = { backdrop = 100, -- Disable dark background }, + files = { actions = { - files = { ["ctrl-x"] = actions.file_split, ["ctrl-v"] = actions.file_vsplit, ["ctrl-t"] = actions.file_tabedit, ["ctrl-q"] = actions.file_sel_to_qf, }, - buffers = { + }, + buffers = { + actions = { ["ctrl-x"] = actions.buf_split, ["ctrl-v"] = actions.buf_vsplit, ["ctrl-t"] = actions.buf_tabedit,
actions.buffers
was used for all buffer type pickers, this meant also tabs and lines, etc. - that’s why it worked in the past.
I made it simpler so actions.files
sets the actions for all pickers with file or buffer entries.
if you wanted to change the binds for :FzfLua buffers
then indeed you need to define buffers.actions
.