When using ag
on the command line, like so:
$> ag . --ignore="*node_modules/*/node_modules" -l --nocolor -f -U -g ""
I am able to avoid searching through any node_modules directories more than one level deep in my node services, which is the desired behavior.
However, when I use the following in my vimrc, the node_modules directories more than one level deep are not ignored:
" Use The Silver Searcher https://github.com/ggreer/the_silver_searcher
if executable('ag')
" Use Ag over Grep
set grepprg=ag\ --nogroup\ --nocolor
" Use ag in CtrlP for listing files. Lightning fast and respects .gitignore
let g:ctrlp_user_command = 'ag %s --ignore="*node_modules/*/node_modules" -l --nocolor -f -U -g ""'
endif
How can I set up ag
and ctrlp
to correctly ignore those directories?
Not sure if I need to use a different syntax (like regex) or some other gotcha when transplanting to vimrc.
The reason I'm not putting this in the wildignore is that node_modules are ignored in my .gitignore, so I'm using the -U
option to ignore any vcs files (thereby allowing ag
to search node_modules) -- but this option also seems to bypass the wildignore.
Like you I do use both tools, but the way I ignore folders is different
For Ag I use the .agignore
file, it has the same sintax as .gitignore
and just like it, it can go in your home folder or project folder.
Not sure if that will solve your problem with Ctrlp, in any case it is quite fast already for me so I use the normal ignore variable like this:
let g:ctrlp_custom_ignore = {
\ 'dir': '\v[\/](doc|tmp|node_modules)',
\ 'file': '\v\.(exe|so|dll)$',
\ }
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