nvim-telescope / telescope-live-grep-args.nvim

Live grep with args
727 stars 40 forks source link

How to filter keyword by regex_patern of folder? #19

Closed Tej12345 closed 2 years ago

Tej12345 commented 2 years ago

Telescope live_grep is missing the feature when you could find a grep pattern in particular folders.(regex folders)

I want to see something like:

  1. Telescope live_grep
  2. Write into input box e.g.: define --folder "*playground*
  3. Get results of define keyword in under everyfolder which has playground keyword.

It's really annoying to do this by going to: 1) Move results to quickfix window (Pressing C-q) 2) Filtering results with :Cfilter playgound

Please, this nvim plugin is really great so far, but this feature I MISS so much... Thank you, Nikita

weeman1337 commented 2 years ago

Hi @Tej12345 thanks for your question.

Assuming you are running rg you can do this:

For more examples you can also check the ripgrep guide

Tej12345 commented 2 years ago

Thank you, man!

weeman1337 commented 2 years ago

I may add some examples to the README. So please keep the issue open.

johhnsmmith198 commented 2 years ago

Hey @weeman1337 I sometimes need to search on a sibling folder. For instance -g ../other-project/** define but this doesn't work. any advise of how to target a specific folder with your extension? rg would allow a path at the end of the command

ripgrep defaulted to searching your current directory in the absence of a path. In general, rg foo is equivalent to rg foo ./.

weeman1337 commented 2 years ago

Hi @johhnsmmith198 :wave:

I think -g does not work because it defines a glob in the search path. As you found out it is ./..
So providing another path should work: "define" ../other-project

I am currently working on a shortcut to quote the current prompt. So that adding path/params will be easier.

johhnsmmith198 commented 2 years ago

Hey @weeman1337 You can try it, it doesn't work. Something that works is: "define" ../ but as soon as I explicitly state a folder: "define" ../project or "define" ../project/ or "define" ../project/** it doesn't work anymore

weeman1337 commented 2 years ago

Works for me (where cwd is not engelsystem):

grafik

Does it work from the shell @johhnsmmith198 ?

johhnsmmith198 commented 2 years ago

sorry you are right. I took it step by step and did it in the terminal then again in nvim and yes it works. Thank you so much. Excellent plugin !