Skip to content
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

Improve live_grep #1818

Closed
otavioschwanck opened this issue Apr 4, 2022 · 7 comments
Closed

Improve live_grep #1818

otavioschwanck opened this issue Apr 4, 2022 · 7 comments
Labels
enhancement Enhancement to performance, inner workings or existent features

Comments

@otavioschwanck
Copy link

Recently i migrated from emacs to vim, im loving the performance, etc.

But i missing something crucial: The project text finder is a little weak and too poluted.

Here is a comparassion:

Searching stableCoin on project and filtering for filename that contains sol (you can divide the search with #)

Emacs:
image

Neovim:
image

On telescope, it repeats the file a lot of times., make it poluted.
On telescope i cannot filter by filename (i have to use grep_string with search=)

Emacs: Doom Emacs default search

@otavioschwanck otavioschwanck added the enhancement Enhancement to performance, inner workings or existent features label Apr 4, 2022
@ghost
Copy link

ghost commented Apr 5, 2022

It seems like string_grep and live_grep have the two halves to what we want; they're just not put together.

String_grep greps for an initial term and the results can be filtered by typing additional terms in the telescope prompt, but string_grep takes only the word under cursor for the initial term; you can't enter it on command line or in Telescope prompt. live_grep lets you enter the initial term but you can't narrow the results by typing in additional terms.

The way it works on Emacs (at least with consult-ripgrep, which is what I used), is that you can type in the initial term in the prompt, then the command seamlessly accepts any additional terms as filters on the initial results.

edit: This gets pretty close to the Emacs way, though you don't get any preview or completion with the initial input term: require ('telescope.builtin.files').grep_string({search = vim.fn.input("Search term: ")})

@tapayne88
Copy link
Contributor

I wanted something like this, so I use the telescope-rg extension which gives you access to rg.

Now to search for stableCoin and filtering for filename that contains sol I'd do

stableCoin -t sol

or perhaps

stableCoin -g *.sol

You can get pretty advanced with the glob matching so you can exclude tests with -g !**/tests/** etc. Everything you can do with ripgrep.

Another example searching in my dotfiles
Screenshot 2022-04-06 at 12 42 02

@otavioschwanck
Copy link
Author

otavioschwanck commented Apr 6, 2022

I wanted something like this, so I use the telescope-rg extension which gives you access to rg.

Now to search for stableCoin and filtering for filename that contains sol I'd do

stableCoin -t sol

or perhaps

stableCoin -g *.sol

You can get pretty advanced with the glob matching so you can exclude tests with -g !**/tests/** etc. Everything you can do with ripgrep.

Another example searching in my dotfiles Screenshot 2022-04-06 at 12 42 02

Telescope rg is OK, but still not good enough.

1- I can't separate the search with space unless i put 'my search'
2 - I have to remember the *file*sol exactly to works
3 - I have to put the search in order, if i want to find: 'senior token', on emacs e can put 'token senior' and it will get it, that easy.

@mildavw
Copy link

mildavw commented Jun 29, 2022

I was looking for the same functionality and found: https://github.com/ibhagwan/fzf-lua

The command is live_grep_glob() and it seems to give you what you want with stableCoin<C-g>sol

@otavioschwanck
Copy link
Author

I was looking for the same functionality and found: https://github.com/ibhagwan/fzf-lua

The command is live_grep_glob() and it seems to give you what you want with stableCoin<C-g>sol

This is exactly what i want for telescope!

@Conni2461
Copy link
Member

You can now refine your live grep search and move to a fuzzy environment with <c-space>. Can be configured see #2034

@rsdenijs
Copy link

@Conni2461 That is awesome. I think this feature should be advertised more prominently!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Enhancement to performance, inner workings or existent features
Projects
None yet
Development

No branches or pull requests

5 participants