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

Fuzzy live args or autocomplete live args #72

Open
nullromo opened this issue Nov 7, 2023 · 2 comments
Open

Fuzzy live args or autocomplete live args #72

nullromo opened this issue Nov 7, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@nullromo
Copy link

nullromo commented Nov 7, 2023

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 ./myTabEnter. 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:

  1. (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 with m; when I type y-spe it will refine the results, etc.
  2. (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 nullromo added the enhancement New feature or request label Nov 7, 2023
@mebble
Copy link
Contributor

mebble commented Jul 27, 2024

@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.

@nullromo
Copy link
Author

@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.

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

2 participants