For my repo, suppose it's called top
top\
.gitignore
foo\
bar\
I want CtrlP to list files that are
foo\
.gitignore
defined in top\
If I cd into top\foo\
, and open vim from there, 1 would be satisfied but not 2.
If I open vim on top\
, 2 would be satisfied but not 1.
How do I achieve both 1 and 2?
I tried this gitignore vim script, but it only parses gitignore
when I open vim in the root folder of a repo, so I can't do both 1 and 2 together.
Same for let g:ctrlp_user_command = 'ag %s -l --nocolor -g ""'
, ag
doesn't try to go up to the repo root and read gitignore from there.
Setting g:ctrlp_working_path_mode
as r
let CtrlP honors .gitignore
in the top folder, but everything under top\
would be listed by CtrlP. I just want files in foo\
.
Thanks.
Seems there is no apparent way to do it, so I just followed @kamaradclimber 's suggestion, spent an hour and made this: RootIgnore
Never coded in VimScript before so it took me some time :-)
You can install it using Vundle.
It searches upward recursively for .git
dir, gets the .gitignore
in the same dir as the .git
dir, and sets wildignore
accordingly.
Update:
@jthill's method works better than mine.
But CtrlP has custom search commands while CommandT does not. So my plugin can still be useful to CommandT users.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With