nvim-telescope / telescope.nvim

Find, Filter, Preview, Pick. All lua, all the time.
MIT License
15.9k stars 835 forks source link

Make live_grep behave like `:Ag` does when using fzf.vim #2579

Closed no-more-secrets closed 1 year ago

no-more-secrets commented 1 year ago

I just migrated from fzf.vim to Telescope, and the only thing I am a bit unsatisfied with is that Telescope does not seem to have an equivalent of :Ag. When I used to type :Ag with fzf.vim, a window would open and it would immediately start searching and indexing all lines in all files under the current folder. Then, as I type stuff, it would not run a new ag command, it would instead use fzf to filter existing results.

Now, I am using Telescope+Rg, and it does not appear to work the same way... each time I type something into the search box it does a new Rg search, and I can't use the fzf filter language to filter the results even though I have fzf enabled as my filterer for Telescope.

Conni2461 commented 1 year ago

We have the same behavior with Telescope grep_string search= but you should make sure you install fzf algorithm: https://github.com/nvim-telescope/telescope-fzf-native.nvim fzf binary not needed.

live_grep is just a different feature, enabling different use cases (regex, ...)

no-more-secrets commented 1 year ago

@Conni2461 Thanks, I had tried Telescope grep_string search= but it wasn't including all (non-ignored) files under my current folder. However, I now realize what the problem is: once the window opens and it starts reading/indexing files, as soon as I start typing filtering text, it stops reading in new files.

So, if I open vim in my home folder (under which there are many many files) and do Telescope grep_string search=, it will eventually index all files if I don't type any keys, but if I do type a key then it will stop. Is it feasible to fix that? The fzf-vim version allows you to start filtering as files are being read, and does no stop as you are typing, it just expands teh results as new matches come in, and that is good because typically you find what you are looking for before all files are indexed.

Should I raise a new issue for that?

Conni2461 commented 1 year ago

rg doesnt read in hidden files on default, you need to enable that by setting --hidden, :lua require("telescope.builtin").grep_string{ search = "", additional_args = {"--hidden"} }

we still index everything in the background but the frontend/ui isnt updating after that anymore until we are done with indexing, that is an ongoing issue and we worked on fixing this issue here https://github.com/nvim-telescope/telescope.nvim/pull/1491

no-more-secrets commented 1 year ago

@Conni2461 ok thx, I guess we can close this.

One more note: I've noticed that Telescope (and vim itself) can crash while Telescope is indexing ~6-7k files during a Telescope grep_string search=... is that a known issue, or should I open a separate issue for that? I can reproduce that consistently on my system when I am in a folder that has ~10k files under it, even though I have a lot of RAM.

Conni2461 commented 1 year ago

didn't happen to me with 110k files but i also have 32gb of memory

ogabriel commented 1 year ago

@Conni2461 ok thx, I guess we can close this.

One more note: I've noticed that Telescope (and vim itself) can crash while Telescope is indexing ~6-7k files during a Telescope grep_string search=... is that a known issue, or should I open a separate issue for that? I can reproduce that consistently on my system when I am in a folder that has ~10k files under it, even though I have a lot of RAM.

This problem happens to me with 4.4K files, and I have a 16GB of memory.

The repository that crashes for me it's open, is this one: https://github.com/zanfranceschi/rinha-de-backend-2023-q3, it has many big html and log files (resulting from the gatling stress test tool)

Using the .rgignore file to ignore the folder with the tests prevents the crash or slow loading of lines

But it would be good if Telescope grep_string search= continued to load new files "in" as you type, just as live_grep