Fuzzy live args or autocomplete live args
nullromo opened this issue · 2 comments
Is your feature request related to a problem? Please describe.
I'm new to Telescope. I want to search for a specific string (foo
) within a specific folder (my-specific-folder-name-cool-awesome
). I can do this on the command line using rg foo ./my
TabEnter. However, if I invoke Telescope live grep and type in "foo" ./my
, there's nothing I can do except keep on typing -specific-folder-name-cool-awesome
before any of the results show up.
Describe the solution you'd like
I would like to be able to search for a given string within a given folder and not have to type in the full folder name.
This could be achieved in one of 2 ways:
- (more desirable) Fuzzification of the directory argument such that when I type
"foo" ./m
the results are already starting to show up for any "foo" matches in any folders that start withm
; when I typey-spe
it will refine the results, etc. - (less desirable) Some kind of autocomplete so that I can use the method described above with the Tab key.
When using something that is ostensibly a fuzzy searcher, it's a bit weird to type something, see a bunch of results, keep typing, see ZERO results, then keep typing and suddenly see more results. I would expect the results list to only shrink as I type more, never grow. But here I can type "foo" ./my-specific-folder-name-cool-awesom
and have no results, then just add the e
and suddenly more results appear.
Describe alternatives you've considered
For now I have been just typing out the full folder name and it works fine, but it's harder to use.
Additional context
Before recently, I used to have a bashrc line like alias search='grep -irn --exclude-dir=node_modules/ --exclude-dir=.git/ --exclude=Session.vim ........'
and I would Ctrlz out of vim, use search ...
, look at the results, then fg
back into vim and open up files. Telescope seems waaaay better than that, but I'd like to be able to replicate that same functionality within vim.
@nullromo this is exactly what I was looking for as well. I was disappointed that this didn't seem to do fuzzy search on directories. Luckily there's require('telescope.actions').to_fuzzy_refine
, which will take whatever results already appear and fuzzy search over them. I've made a telescope keybind like this:
require('telescope').setup {
defaults = {
mappings = {
i = {
['<C-f>'] = require('telescope.actions').to_fuzzy_refine,
},
},
}
}
Now I can type "foo" and press <C-f>
to then fuzzy search over all the directories that "foo" is found in. This keybind in fact works on all telescope pickers. So glad I found this.
@mebble This is cool! Didn't know about it either.
It's not perfect. For example, if you want to search for foo
in a folder called server
, you can get results like
server/files/asdf.ts:30:22: foo
dir/dir/dir/server/asdf.ts:30:22: foo
please/swerve/right/asdf.ts:30:22: foo
se rve r
But for the most part it works pretty well for what I need.