Vim Ctrlp does not parse Ag (silver search) - choose the right option

When using ag on the command line:

$> ag . --ignore="*node_modules/*/node_modules" -l --nocolor -f -U -g ""

I can avoid searching in any node_modules directories more than one level in my node services, which is the desired behavior.

However, when I use the following in my vimrc, node_modules directories of more than one depth level 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 to configure ag and ctrlp to correctly ignore these directories? Not sure if I need to use another syntax (e.g. regex) or any other information when transplanting to vimrc.

The reason I don't put this in wildignore is because node_modules are ignored in my .gitignore, so I use the -U option to ignore any vcs files (thereby allowing ag to search for node_modules) - but this option also, seems to bypass wildignore.

+6
source share
1 answer

Like me, I use both tools, but the way to ignore folders is different

For Ag I use a .agignore file, it has the same sintax as .gitignore , and just like it, it can be in your home folder or project folder.

Not sure if this will solve your problem with Ctrlp , anyway it's pretty fast for me, so I use the usual ignore variable as follows:

 let g:ctrlp_custom_ignore = { \ 'dir': '\v[\/](doc|tmp|node_modules)', \ 'file': '\v\.(exe|so|dll)$', \ } 
+6
source

Source: https://habr.com/ru/post/971507/


All Articles