-
Notifications
You must be signed in to change notification settings - Fork 170
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: Improved FzfLua resume #1686
Comments
I also think it would be good to swap 'Esc' and 'A-Esc.' So, 'Esc' should hide the picker by default, and 'A-Esc' should terminate. That would provide better defaults in my opinion |
I’m going to create a profile (name suggestion welcome) that if setup will change this behavior for the user. You’ll be able to set it from require("fzf-lua").setup({"hide"}) -- or whatever name we come up with We might beed two profiles one for hide and another for “sticky” for what you wanted in the other issue. |
Is the "hide" profile about the closing process and "sticky" about hiding the window? Did I understand that correctly? Will the "sticky" profile be the default? I just don't get why anyone would want to use the "hide" profile then if it only has downsides, like not being able to fully use FzfLua resume. Or did I miss something, and it could actually be better for someone because we free up memory right after the picker closes, for example? |
I’m not sure myself haven’t given it much thought yet, “hide” would be just replacing abort with hide.
Nothing will be the new default unless you specifically set it to be. There is a potential downside to “hide” which is the process running in the background say you started a long running operation like grep_project on a huge project hide continues the process in the background consuming CPU (a lot of it sometimes), might not be desirable. |
@phanen, just did some testing, It’s also not supported by skim or fzf < 0.36 but I deem that a non issue. |
Started work on this in the hide branch, don’t try it yet as I as to leave mid way so it’s not working :) |
That's weird, they are different when do multi-select: FZF_DEFAULT_OPTS=--multi bash mini.sh '+lua fzf=require"fzf-lua"' '+lua fzf.files{actions={enter={fn=fzf.hide,exec_silent=true}}}'
FZF_DEFAULT_OPTS=--multi bash mini.sh '+lua fzf=require"fzf-lua"' '+lua fzf.files{actions={enter={fn=fzf.hide,reload=true}}}' (patch mini.sh to make it allow nvim args: -HOME=${TEMPDIR} PACKPATH=${packpath} ${nvim_bin} -u ${tmp_rtp}/${plug_name}/scripts/init.lua
+HOME=${TEMPDIR} PACKPATH=${packpath} ${nvim_bin} -u ${tmp_rtp}/${plug_name}/scripts/init.lua "$@" |
@phanen, I'm not sure if I'm getting it, you set the action It seems everything working as expected for me, can you both try the hide branch and lmk if it works well for you @miroshQa, @phanen? |
@ibhagwan No, sorry for my poor explaining. With these command you should have launch fzf win, then:
Then People use this "hide" profile usually just select one -> hide -> resume and select another one -> hide... Nothing different in this case. But when select multiple one -> hide -> resume, select multiple one again... I personally rely on the behavior of
Crash with require('fzf-lua').setup {
'hide',
actions = {
files = { ['alt-q'] = { fn = fa.file_sel_to_qf, prefix = 'select-all' } },
},
}
I guess |
Reload is completely different action, it’s used to reload the list completely, an example would be git_status after a stage/unstafe, you want to reload the list to get the new file status.
Maybe you can bind a key in fzf to clear-selection or toggle-selection?
Can be used together this is a bug, I just have add the prefix to the action |
Another bug, only happened when you set more than 8 binds... {
"hide",
actions = {
files = {
["alt-1"] = function() end,
["alt-2"] = function() end,
["alt-3"] = function() end,
["alt-4"] = function() end,
["alt-5"] = function() end,
["alt-6"] = function() end,
["alt-7"] = function() end,
["alt-8"] = function() end,
["alt-9"] = function() end,
-- ["alt-0"] = function() end,
},
},
} Then |
Everything works well! 👍 |
@phanen, easy fix, probably just need to increase the size of our circular buffer caching the fzf callbacks: Line 15 in 6f72497
|
@phanen, try the latest commit? Both |
@ibhagwan Everything work fine for me now. Thanks for your works! |
With 10+ custom binds in files we get to a 20 registered functions, changed the ring buffer size to 50, should hopefully be fine for a while, I'm thinking how can I eliminate these callbacks but doesn't seem like possible, even with |
The profile changes the default binds to hide the fzf-lua window instead of aborting it, therefore keeping cursor position, selection, etc. Note that this also continues long running operations in the background so be mindful of sending fzf to background on a large mono repo, can still be aborted with `ctrl-c` or `alt-esc`. Enable with: ```lua -- Set as base profile :lua require("fzf-lua").setup({"hide"}) -- More than one profile :lua require("fzf-lua").setup({"border-fused","hide"}) -- Or with `profiles`: :FzfLua profiles load=hide -- More than one profile :FzfLua profiles load={"border-fused","hide"} ```
321b545, wrote proper commit message, gonna give this a few days of testing and feedback and take it from there. |
Shouldn't this README tip be changed to something like this? Tip By default, pressing Esc or selecting any entry terminates the fzf process. As such, the resume feature is not perfect and is limited to resuming the picker query and sometimes additional parameters, such as regex in grep. For a more "complete" resume, use the "hide" profile. This will keep the fzf process running in the background, allowing "FzfLua resume" to restore the picker state entirely, including cursor position and selection. To configure hiding by default: require("fzf-lua").setup({
"hide",
-- your other settings here
}) |
Good idea @miroshQa, not sure if it’s possible to submit a PR to the PR but I can add it later :) |
The profile changes the default binds to hide the fzf-lua window instead of aborting it, therefore keeping cursor position, selection, etc. Note that this also continues long running operations in the background so be mindful of sending fzf to background on a large mono repo, can still be aborted with `ctrl-c` or `alt-esc`. Enable with: ```lua -- Set as base profile :lua require("fzf-lua").setup({"hide"}) -- More than one profile :lua require("fzf-lua").setup({"border-fused","hide"}) -- Or with `profiles`: :FzfLua profiles load=hide -- More than one profile :FzfLua profiles load={"border-fused","hide"} ```
The profile changes the default binds to hide the fzf-lua window instead of aborting it, therefore keeping cursor position, selection, etc. Note that this also continues long running operations in the background so be mindful of sending fzf to background on a large mono repo, can still be aborted with `ctrl-c` or `alt-esc`. Enable with: ```lua -- Set as base profile :lua require("fzf-lua").setup({"hide"}) -- More than one profile :lua require("fzf-lua").setup({"border-fused","hide"}) -- Or with `profiles`: :FzfLua profiles load=hide -- More than one profile :FzfLua profiles load={"border-fused","hide"} ```
|
Another two issues for
|
The profile changes the default binds to hide the fzf-lua window instead of aborting it, therefore keeping cursor position, selection, etc. Note that this also continues long running operations in the background so be mindful of sending fzf to background on a large mono repo, can still be aborted with `ctrl-c` or `alt-esc`. Enable with: ```lua -- Set as base profile :lua require("fzf-lua").setup({"hide"}) -- More than one profile :lua require("fzf-lua").setup({"border-fused","hide"}) -- Or with `profiles`: :FzfLua profiles load=hide -- More than one profile :FzfLua profiles load={"border-fused","hide"} ```
Fixed in the last force push ced1e22
All of the exit chain isn’t called as the process is sent to background, colorschemes doesn’t restore the original scheme on hide as well, to fix last query I’d have to resort to extracting it from the window object as I used to in the past (instead of relying on |
The profile changes the default binds to hide the fzf-lua window instead of aborting it, therefore keeping cursor position, selection, etc. Note that this also continues long running operations in the background so be mindful of sending fzf to background on a large mono repo, can still be aborted with `ctrl-c` or `alt-esc`. Enable with: ```lua -- Set as base profile :lua require("fzf-lua").setup({"hide"}) -- More than one profile :lua require("fzf-lua").setup({"border-fused","hide"}) -- Or with `profiles`: :FzfLua profiles load=hide -- More than one profile :FzfLua profiles load={"border-fused","hide"} ```
The profile changes the default binds to hide the fzf-lua window instead of aborting it, therefore keeping cursor position, selection, etc. Note that this also continues long running operations in the background so be mindful of sending fzf to background on a large mono repo, can still be aborted with `ctrl-c` or `alt-esc`. Enable with: ```lua -- Set as base profile :lua require("fzf-lua").setup({"hide"}) -- More than one profile :lua require("fzf-lua").setup({"border-fused","hide"}) -- Or with `profiles`: :FzfLua profiles load=hide -- More than one profile :FzfLua profiles load={"border-fused","hide"} ```
The profile changes the default binds to hide the fzf-lua window instead of aborting it, therefore keeping cursor position, selection, etc. Note that this also continues long running operations in the background so be mindful of sending fzf to background on a large mono repo, can still be aborted with `ctrl-c` or `alt-esc`. Enable with: ```lua -- Set as base profile :lua require("fzf-lua").setup({"hide"}) -- More than one profile :lua require("fzf-lua").setup({"border-fused","hide"}) -- Or with `profiles`: :FzfLua profiles load=hide -- More than one profile :FzfLua profiles load={"border-fused","hide"} ```
The profile changes the default binds to hide the fzf-lua window instead of aborting it, therefore keeping cursor position, selection, etc. Note that this also continues long running operations in the background so be mindful of sending fzf to background on a large mono repo, can still be aborted with `ctrl-c` or `alt-esc`. Enable with: ```lua -- Set as base profile :lua require("fzf-lua").setup({"hide"}) -- More than one profile :lua require("fzf-lua").setup({"border-fused","hide"}) -- Or with `profiles`: :FzfLua profiles load=hide -- More than one profile :FzfLua profiles load={"border-fused","hide"} ```
The profile changes the default binds to hide the fzf-lua window instead of aborting it, therefore keeping cursor position, selection, etc. Note that this also continues long running operations in the background so be mindful of sending fzf to background on a large mono repo, can still be aborted with `ctrl-c` or `alt-esc`. Enable with: ```lua -- Set as base profile :lua require("fzf-lua").setup({"hide"}) -- More than one profile :lua require("fzf-lua").setup({"border-fused","hide"}) -- Or with `profiles`: :FzfLua profiles load=hide -- More than one profile :FzfLua profiles load={"border-fused","hide"} ```
Closed via 34907b3 |
@ibhagwan Hmm, I updated the plugin to the latest version, and now the escape key closes the picker with a noticeable delay. It becomes even more interesting because if I manually change 'esc' to hide instead of selecting the 'hide' profile it becomes much faster Slow escape config return {
"ibhagwan/fzf-lua",
keys = {
{ "<leader>f", function() require('fzf-lua').files() end },
{ "<leader>'", function() require('fzf-lua').resume() end },
},
config = function()
require("fzf-lua").setup({
"hide",
files = {
git_icons = false,
},
winopts = {
row = 0.5,
width = 0.8,
height = 0.8,
preview = {
horizontal = 'right:50%',
scrollbar = false,
},
backdrop = 100,
},
})
end
} Fast escape config return {
"ibhagwan/fzf-lua",
keys = {
{ "<leader>f", function() require('fzf-lua').files() end },
{ "<leader>'", function() require('fzf-lua').resume() end },
},
config = function()
require("fzf-lua").setup({
files = {
git_icons = false,
},
winopts = {
row = 0.5,
width = 0.8,
height = 0.8,
preview = {
horizontal = 'right:50%',
scrollbar = false,
},
backdrop = 100,
},
keymap = {
builtin = {
true,
["<esc>"] = "hide",
}
}
})
end
}
|
Reproduced, I've been always binding my |
@phanen is correct, this is due to I’ll look into getting the query data from the term buffer instead, if I leave everything in neovim it will be faster. |
Maybe escape shouldn't save the query to the history? For me, it makes sense to save something to the history only if I choose something (Enter, Ctrl + V, etc.). |
We can skip the history but we do need last query for picker specific resume (think hide then restart a new picker, now use the old picker with resume=true). |
No delay now, nice! |
Fantastic, Ty for the update @miroshQa! |
|
And that's the downside of using query extraction from the prompt, do you have these set in I wasn't aware |
I will, but there's also
Try new feature just now. The
With
|
Maybe it can be tricky:
|
And And |
This will cause significant delays on typing, especially on Windows.
I don’t like giving this offloading this to the user, it’s a source of issues.
This gets converted to Lines 628 to 634 in 75a7e16
This should be fixed indeed. This issue has gone too long and is already closed, we should open a new issue with all the edge cases we wish to solve and I’ll think of something, maybe |
I will open a new issue.
Sorry but what's the right way to force my prompt to be always something like '❯ ': |
I have an idea very close to a better solution, hide the window first and then send an addittional esc to the fzf window (for the execute-silent action) but I can't find a way to queue nvim keys to a specific buffer, check it out maybe you have an idea?
defaults = { prompt="❯ " } |
How about api.nvim_chan_send(term, vim.keycode("<Esc>")) |
Good idea, I’ll be able to try it in a few hours. |
Track in #1731. |
Have you RTFM'd?
Feature Request
Continuation of #1595
Problem:
Currently, ":FzfLua resume" is very limited compared to ":Telescope resume" because all picker actions that select an entry close the fzf process, so ":FzfLua resume" works by rerunning the picker again. However, rerunning the picker again is inefficient, and we also lose the selected entry position.
Solution:
All "select entry" actions should hide the picker by default instead of closing the process and performing the corresponding action (open file, etc.). It turned out to be possible to implement according to the discussion in #1595.
The text was updated successfully, but these errors were encountered: