How to switch to file picker if buffer picker returns no matches? #2575
-
|
I'm trying to figure out how to efficiently switch to the file picker if the buffer picker returns no matches. My current workflow is to open the buffer picker, type a filename, realize that the buffer picker shows no matches because the file isn't open yet, then exit the buffer picker, open the file picker, and re-type the filename to find the file. This feels slow and annoying. I would like to be able to open the buffer picker, type the filename, then press a keyboard shortcut (e.g. Ctrl-F) to switch to the file picker, keeping the current input so that I don't have to re-type the filename. Alternatively, the buffer picker could automatically switch to to the file picker as soon as there are no matching buffers. There's the obvious solution of a combined buffers+files picker with buffers listed first, but I don't like that solution because it feels inefficient to have to list all the project files every time I want to switch buffers, especially on very large projects. Does anyone have ideas for how to achieve my desired workflow, or alternative solutions I haven't considered? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
require("fzf-lua").buffers({
actions = {
zero = function()
require("fzf-lua").files()
end,
},
})You can also try |
Beta Was this translation helpful? Give feedback.
-
|
To keep the query: require("fzf-lua").buffers({
actions = {
zero = function()
vim.defer_fn(function()
local query = require("fzf-lua").get_info().query
require("fzf-lua").files({ query = query })
end, 10)
end,
},
}) |
Beta Was this translation helpful? Give feedback.
Thanks! This got me on the right track, though I had to make a few changes:
.get_info().querydidn't work for me for whatever reason, so I used.get_last_query()instead.defer_fnleads to some weird behavior if I type too fast, I think it briefly exits the picker and then my next input char becomes a normal mode command. So removingdefer_fnfixes that.Here's my updated version: