nvim-telescope / telescope-fzf-native.nvim

FZF sorter for telescope written in c
1.43k stars 46 forks source link

correct way to pcall telescope-fzf-native for optional usage in lazy #96

Open matu3ba opened 1 year ago

matu3ba commented 1 year ago

AFAIk lazy requires manual calls of :Lazy build and more over I'd like to have a general solution for optional plugin installations.

So far I tried:

-- pcall on telescope extension does not work:
-- local ok_fzf, _ = pcall(require, 'fzf-native')
-- local ok_fzf, _ = pcall(require, 'fzf_lib')
-- local ok_fzf = pcall(telescope.load_extension, 'fzf_lib')
-- assert(ok_fzf)
telescope.load_extension('fzf')

and I have seen exactly 1 instance (which also did not work) of

pcall(telescope.load_extension, 'fzf')

Note, lazy plugin usage is

{ "nvim-telescope/telescope-fzf-native.nvim", build = "make", lazy = false }, -- 1.65x speed of fzf

and then :Lazy build telescope-fzf-native

Suggestions welcome.

swy7ch commented 1 year ago

I was messing with lazy, coming from packer... And spent the last 20 minutes figuring out why it wouldn't build. I'm very interested in the reason, and the solution for optional installations.

Anyhow, thanks for the workaround :)

swy7ch commented 1 year ago

Alright I finally took the time to figure it out. I did have to search for it a bit on https://github.com/folke/lazy.nvim as I suspected it was more an issue with lazy than this extension...

And it -- kind of -- is. As you can read here [0], "lazy would not automatically build again if the plugin is already installed or not updated". In my case, I had the build command written as run when starting off the first time (coming from packer), which prevented the build from happening.

It's a hard thing to debug, but I wiped my lazy directory in ~/.local/share/nvim/lazy to start off fresh and it seems to build correctly. Hope this helps ! :)

[0] https://github.com/folke/lazy.nvim/issues/119#issuecomment-1385193566