Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vim Ctrlp not parsing Ag (silver search) --ignore option correctly

Tags:

vim

ctrlp

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 image 790
user1797466 Avatar asked Jun 29 '14 18:06

user1797466


1 Answers

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)$',
  \ }
like image 199
SystematicFrank Avatar answered Sep 20 '22 16:09

SystematicFrank