cloudhead / neovim-fuzzy

Minimalistic fuzzy file finding for neovim
BSD 3-Clause "New" or "Revised" License
111 stars 17 forks source link

Support searching inside the files themselves #6

Closed jedahan closed 8 years ago

jedahan commented 8 years ago

with fzf.vim, I was able to add this:

function! s:with_git_root()
    let root = systemlist('git rev-parse --show-toplevel')[0]
    return v:shell_error ? {} : {'dir': root}
endfunction

command! -nargs=* FzfGit call fzf#vim#ag(<q-args>, extend(s:with_git_root(), g:fzf#vim#default_layout))
map <C-s> :FzfGit

which meant that control-s would do a search of the contents of all the git files, and then I could fuzzy find the list, and then hit enter and open the found file. what's the best way to do this with neovim-fuzzy?

cloudhead commented 8 years ago

I wanted to do this so I added a FuzzySearch command which should behave similarly, except that like FuzzyOpen it searches from the current directory. It's currently in the dev branch if you want to try it.

jedahan commented 8 years ago

So that is really cool, but works a little bit different than I anticipated: it searches the filenames as well as the contents. So if I have a file called cart.rs, and I want to search for 'cart', it shows every line in cart.rs as matching.

Another interesting thing is that the FzfGit example I showed above, I can do: :FzfGit cart , which will first do a full rg search for 'cart', and then in nvim, those results I can filter those results more using normal fzf. I hope this makes sense, I wish I had a gif to explain.

cloudhead commented 8 years ago

As far as I know, fzf works that way too, at least with the :Ag command and the one you pasted above. Does it work differently for you? It's due to how fzf/fzy are implemented: it's just matching on a string which includes the filename and then extracts the filename from the match. I'd love to have it not match on the filename though.

The example with the pre-filtering is nice though, I can include that easily.

cloudhead commented 8 years ago

This is now in master, under :FuzzyGrep, it also takes optional arguments. I'll deal with the git tree thing separately. If you are able to get fzf.vim to search without it matching on the filenames, let me know, as I haven't been able to reproduce it here.