cloudhead / neovim-fuzzy

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

Include all files within a "project" #3

Closed gfairchild closed 7 years ago

gfairchild commented 8 years ago

Right now, this plugin seems to only find files within pwd. I write a lot of Django projects that have a structure like this:

apps/
  app1/
  app2/
settings.py
urls.py
templates/
  base.html
  app1/
  app2/
...

If I cd into apps/app1 and open a file for editing, I can't hit CTRL+P to find/open base.html, for example, because base.html doesn't live under apps/app1. ctrlp.vim searches for all files within the project root by default (I guess it detects all files within the current Python environment?). Is there a way for this plugin to do the same?

cloudhead commented 8 years ago

Hmm, the simplest thing I can think of would be to find the first .git directory, which is usually at the project root of most projects. I typically avoid this by always opening vim from the root folder, and using Ctrl-P to find the file I want.

I think I could add an option to search for the first file that matches a certain pattern and consider that the search root. It would default to .git, but could be anything. Would that solve the problem?

gfairchild commented 8 years ago

That sounds like a totally reasonable way to solve this. I like defaulting to .git if it exists in the directory hierarchy. Looking more closely at the ctrlp.vim docs, that's basically what it does. See the second bullet point under https://github.com/ctrlpvim/ctrlp.vim#basic-options for more information.

cloudhead commented 8 years ago

Great, I'll come up with something similar, but probably a little simpler. Thanks for the link.

gfairchild commented 8 years ago

Great! Thanks very much for the quick response. I'm loving the plugin. The results seem better than ctrlp.vim, and it's almost instantaneous.

techhazard commented 8 years ago

You can use the following to get the root for a git and mercurial repo. I do not use hg myself, but a quick search came up with this

$ git rev-parse --show-toplevel
$ hg root

note that the git solution stays within a submodule if it's called in one, but there are several ways to detect that

cloudhead commented 8 years ago

Oh that's pretty easy. Will see if I can get that in tonight.

gfairchild commented 7 years ago

Just wanted to check in on this issue to see what the status is. Thanks!

cloudhead commented 7 years ago

Indeed, I've been pushing this back a little because I wasn't sure how I wanted to go about it, but I have an idea now I'm going to try out!

cloudhead commented 7 years ago

I've implemented this behaviour in b5e9e1d1a64b8e8c3b3f49849c5570e67b952546 (master as of now), check it out and let me know if there are any issues.

Currently it defaults to the git or hg root if there is one.

gfairchild commented 7 years ago

This is fantastic! It seems to be working perfectly. Thanks man! This is so much faster than CTRL+P.

cloudhead commented 7 years ago

Awesome. I'll close this, feel free to open a new issue if you encounter any bugs.