Closed gbrlsnchs closed 3 years ago
On my machine, this feels imperceptible to me, could you explain more about which specific delay you are talking about i.e. is it before the window appears on your screen or before? I'm not quite sure why this delay would be caused, could you also provide the specs and operating system of your machine?
@gbrlsnchs are you using keyboard shortcuts to call fzf.fzf
?
On my machine, this feels imperceptible to me, could you explain more about which specific delay you are talking about i.e. is it before the window appears on your screen or before? I'm not quite sure why this delay would be caused, could you also provide the specs and operating system of your machine?
@vijaymarupudi It's a little delay for the floating window to appear, it's a really small delay but perceptible compared to :FZF
.
I'm running on Arch Linux. I don't think it's my specs, like I said, :FZF
opens its window really fast.
@gbrlsnchs are you using keyboard shortcuts to call
fzf.fzf
?
@cpkio Yes, I am! Both :FZF
and fzf.fzf
are called via mappings registered to https://github.com/folke/which-key.nvim.
@gbrlsnchs Try to call corresponding function through command line.
@cpkio I exec'd :lua coroutine.wrap(function() require("fzf").fzf({"choice1", "choice2"}) end)()
and it still has the small delay I mentioned. :cry:
Interesting... I do want to fix this. Does the delay happen when you run this?
vim.cmd "vnew"
vim.fn.termopen("fzf")
vim.cmd "startinsert"
One question: does it use my $SHELL
to execute the command? If that's the case, I'm pretty sure that's why this is happening, since my ZSH has a little startup delay as well. I always use sh
to execute stuff in order to avoid this.
Edit: I ran the commands above and, yes, I felt it has a micro hiccup, which is not present for :FZF
.
That might be it! Try this
vim.cmd "vnew"
vim.fn.termopen({"fzf"})
vim.cmd "startinsert"
I don't know how to benchmark both commands, but I have the impression that vim.fn.termopen({"fzf"})
is a little snappier than vim.fn.termopen("fzf")
.
Nonetheless, both still seem faster than fzf.fzf(...)
. Not sure if it's shell related, though, that was just a guess... also, fzf
(the command, without arguments) seems to open the prompt before loading the input, not sure if that helps with speed as well.
I guess the question is if the second variant seems as fast as :FZF
, since I cannot perceive any difference.
nvim-fzf
doesn't send any data until after the termopen function is executed. It does, however, execute two shell commands currently, one to make a named pipe and one to launch fzf. I can eliminate those, but need data to see if it's worth it.
Yes, vim.fn.termopen({"fzf"})
is as fast as :FZF
.
Great! I've just pushed an optimization patch for this to master, could you test that?
All right, it's as fast as :FZF
now! Nice one, and thanks for the help! :clap:
Great! Thank you for the excellent issue and figuring out that it was the shell that was the cause of the problems.
First of all, thanks for this library, it's awesome! I'm having lots of fun with it. :smile:
One thing that still bites me is this small delay after running
fzf.fzf(...)
and the floating window showing up with FZF ready to be used. I'm comparing this to, say,:FZF
, which is the command that comes with FZF itself.Considering it's not an issue on my side (which could still be), in what ways do you think we could improve this to make it as fast as
:FZF
? I'd be willing to work on this, but I need some pointers. :confused: