telescope-egrepify.nvim icon indicating copy to clipboard operation
telescope-egrepify.nvim copied to clipboard

Use file extension and directory name prefixes on the same prompt

Open jsongerber opened this issue 1 year ago • 3 comments

Is your feature request related to a problem? Please describe. When using extension # and directory name > prefixes on the same telescope prompt, I get result for matches on the extension OR directory, I would like to have matches for the extension AND directory, is it possible?

Describe the solution you'd like Be able to use test >lua #plugins prompt and get results for lua files inside plugins directory

Describe alternatives you've considered None

Additional context This is the current result, the result shown is a lua file but not in the plugins directory image

jsongerber avatar Jul 22 '24 08:07 jsongerber

rg does not directly support this out-of-the-box. The way this would have to be done right now is via piping (cf. link below). This however adds too much complexity. Another way would be to write a parser that joins patterns. That's quite tedious though as well.

See: https://github.com/BurntSushi/ripgrep/issues/875#issuecomment-378089924

PR on latter approach welcome.

fdschmidt93 avatar Jul 22 '24 12:07 fdschmidt93

Thank you for your quick response. I understand that this is not trivial. I still want to give it a shot as this feature is important for me (it could take a few weeks since I don't have a lot of time).

If you think this is too complex and hard to maintain, please let me know and I'll do it quick and dirty in my config.

If you're interested in a PR I have a few questions so that the PR I propose respects your needs, wants, quality requirements, etc:

  • the final pattern could look like this: **/{%s}*/**/*{%s}*.{%s} if all default prefixes are used at the same time, where each %s could be search or search1,search2,..., is that right?
  • Do you want this to be the default behavior, or do you want to keep the default to multiple --glob and have this new behavior opt in with a new config option? If so, what would you want this new config option to be named?
  • I don't have much experience with telescope or this plugin codebase, do you see any caveat or edge case that would make this feature more complex that I think?
  • Any other requirements? Commits naming, PR style, code style?

Thank you!

Edit: After digging into the code, I see that the glob patterns could be much more complex since prefixes can be overridden, and the provided pattern in telescope can also be a glob pattern in itself, so I will need to build a glob pattern parser as you mentioned and then merge those patterns. I don't know how it's feasible, but I will investigate and try if possible

jsongerber avatar Jul 22 '24 16:07 jsongerber

Ex-post: I realize you've answered some questions yourself in the edit, but yes, that is the core problem.

the final pattern could look like this: /{%s}*//{%s}.{%s} if all default prefixes are used at the same time, where each %s could be search or search1,search2,..., is that right?

I remember trying this myself at some point for the reason but discarded it because there will be quite a few edge cases if we would like to do this in a general purpose (all sorts of patterns, etc.) setup. It's probably best to think of ways to isolate this use case (prefixes, simple flags, etc.).

behavior opt in with a new config option

My hunch is uninitiated rg users would expect this behavior by default, coinciding with the typical actual intent of inserting multiple flags. From that end yes, I'd say this probably is a good default. At the same time, the solution will have to be sufficiently robust.

I don't have much experience with telescope or this plugin codebase, do you see any caveat or edge case that would make this feature more complex that I think?

Parsing and merging is not easy ;)

Any other requirements? Commits naming, PR style, code style?

There is a stylua toml in the project that the binary should pick up automatically. CI I recall complains if the PR is not correctly formatted.

fdschmidt93 avatar Jul 23 '24 01:07 fdschmidt93