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

Add Support for Pattern Searching Against Only File Names #87

Open
joeyagreco opened this issue Aug 28, 2024 · 0 comments
Open

Add Support for Pattern Searching Against Only File Names #87

joeyagreco opened this issue Aug 28, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@joeyagreco
Copy link

Is your feature request related to a problem? Please describe.

I love using this plugin like so:

keymap.set(
	"n",
	"<leader>fs",
	telescope.extensions.live_grep_args.live_grep_args,
	helpers.combine_tables(default_options, { desc = "search for words" })
)

This is great for searching for text inside files.

I would like something like this but for searching for files.

Currently I use this from telescope

keymap.set("n", "<leader>ff", telescope_builtin.find_files, helpers.combine_tables(default_options, { desc = "find files" }))

Which does not support ripgrep.

The feature I'm describing was best described here and the solution that I believe makes the most sense is here in the same thread.

Simply adding --files to a pattern does not give the required behavior.

Per rg -h

--files Print each file that would be searched.

The desired behavior is to Print each file where that file name matches the pattern given.


Describe the solution you'd like

Allow for prefixing a search with rg --files | rg so that the search returns filenames that match the pattern given, not filenames that contain matches for the pattern.

This could be in the form of a helper function similar to quote_prompt in telescope-live-grep-args.actions

Which would allow users to configure something like this

local live_grep_args_shortcuts = require("telescope-live-grep-args.shortcuts")
keymap.set("n", "<leader>ff", live_grep_args_shortcuts.grep_for_files)

Ideally, this would work just like telescope.extensions.live_grep_args.live_grep_args but with the above mentioned functionality of only applying the pattern search on file names and only returning file names.


Describe alternatives you've considered
I tried essentially recreating this plugin but for files using Telescope functions.

This was kind of a hassle but I was able to get it somewhat working.

Additional context
Thread referenced earlier: BurntSushi/ripgrep#193

Thanks!

@joeyagreco joeyagreco added the enhancement New feature or request label Aug 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant