nvim-telescope / telescope-fzf-native.nvim

FZF sorter for telescope written in c
1.37k stars 45 forks source link

Failed to install #26

Closed horseinthesky closed 3 years ago

horseinthesky commented 3 years ago

Hi. I have the following packer config:

 use {                                                        
   'nvim-telescope/telescope.nvim',                           
   requires = {                                               
     {'nvim-lua/popup.nvim'},                                 
     {'nvim-lua/plenary.nvim'},                               
     {'nvim-telescope/telescope-fzy-native.nvim', run="make"},
     {'nvim-telescope/telescope-symbols.nvim'},               
   },                                                         
 }                                                            

After adding run="make" clause I get

✗ Failed to install nvim-telescope/telescope-fzy-native.nvim

message when trying to install.

However, the plugin is installed and I can do

require("telescope").load_extension("fzy_native")

perfectly fine. I still cannot check if it is really working though.

Conni2461 commented 3 years ago

I found the issue :) your config says fzy rather than fzf. fzy-native.nvim doesn't have a makefile at project root so you cant run make.

Its also just require('telescope').load_extension('fzf')

horseinthesky commented 3 years ago

I found the issue :) your config says fzy rather than fzf. fzy-native.nvim doesn't have a makefile at project root so you cant run make.

Its also just require('telescope').load_extension('fzf')

Ah. I've mixed the configs of two plugins into one mess. Sorry for bothering =) I didn't quite understand the difference between these two. Could you pls shed some light on it?

Conni2461 commented 3 years ago

No worries. I thought about making a comparison for the readme some time ago. So lets give this a try (i might add this (in some form) later to the readme).

So the idea of the -native sorters is simple. Write the actual score calculation in c and use lua ffi to call the c function for more speed. fzy-native talks about the speed difference between the lua and c implementation of fzy. TLDR: c is like factor 10 faster.

The idea behind fzf-native is to bring the beloved fzf score algorithm to telescope, but junegunn/fzf is not a library and he actual calculation stuff is so tightly coupled that you can't pull it out easily. (fzy-native actually uses original c files from the fzy command line tool and modifies them slightly to make them work better with ffi). So i started porting the algorithm from scratch to c and right now only case for unicodes character is missing.

The difference between fzf-native and fzy-native:

Also just try it and pick which one you like more :) there is no right or wrong here.

horseinthesky commented 3 years ago

@Conni2461 I see some people (Telescopic Johnson) are using both. https://github.com/tjdevries/config_manager/blob/master/xdg_config/nvim/lua/tj/telescope/init.lua

So TJ is loading both extensions and sets file_sorter = sorters.get_fzy_sorter, in telescope config. Is there a reason to do so or using both?

Conni2461 commented 3 years ago

You can't use both. How should that work. You can have both installed and then load one or the other depending on what you do. (I also do that for comparison purpose, etc). If you do file_sorter = sorters.get_fzy_sorter you just set the internal table field file_sorter to the function pointer sorters.get_fzy_sorter. If you then load fzy-native you reset file_sorter and if you load fzf you do it again. So at the end it will point to fzf.get_fzf_sorter function.

I know for a fact that tj did run fzf in the past, because he was testing it before i released it.

Also it doesn't really matter what other people use. As i said before pick the algorithm you like the most :)

horseinthesky commented 3 years ago

@Conni2461 Thanks a lot for the detailed explanation. To pick the one I like is exactly my goal =)

I'm trying each on lua require('telescope.builtin').grep_string() and both spend some time (about 3-4 seconds on 3+ million entries) to find due to making search again and again as I type. At the same time vanilla fzf finds it almost instantly as I type. Btw lua require('telescope.builtin').grep_string({ search = vim.fn.input("Grep For > ")})<CR> also finds it instantly (probably cuz it searches only onve after I press ).

Conni2461 commented 3 years ago

Thats because fzf is a completely compiled command line tool which runs in a floating terminal window. It can and makes use of go routines and is able to do searching parallelized.

Telescope is completely a single core application which uses lua coroutines to unblock the ui so you can type while we search (implemented for all besides live_grep). We are still working on making it better in that regards but we will never reach the fzf speeds because neovim (because all runs in process in neovim, no external cli tool) and lua doesn't offer us to do stuff parallel (at least for now).

If you would be able to only compare this implementation of the fzf algorithm with vanilla fzf, i am pretty sure there wouldn't be any speed differences. (You can't really do it because fzf is really tightly integrated. You would need to refactor it first). I implement the same smart speed improvements, like using a preallocated block of memory and reusing that block for the whole duration of the algorithm and some other optimizations.

So yeah any speed issues aren't the fault of this repository. If you need the speed you should probably stick with vanilla fzf. Its still a great project ;) or you can use both. Nobody prevents you from doing that :laughing:

horseinthesky commented 3 years ago

This is what I am doing =)

Vanilla fzf for finding files and buffer lines. Opening several items in splits/tabs is a killer feature here. Telescope for finding git, lsp, help, mappings and basically speaking everything else. Combo! :D