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.
--ignore
part due to.agignore
. I removed-U
so that ag would still use.gitignore
. And I noticed that ag ignores hidden files by default. – Di