kien/ctrlp.vim — Issue #70: user_cmd options for windows and linux with wildignore
Author: ralesi
Created: 2012-01-09 21:05:04+00:00
State: open

I figured that since standard ctrlp used wildignore that I should set up user_cmd the same way. Just wanted to stick it here in case you wanted to put it in the docs. 'es' is a command line tool to access 'everything' on windows (application to monitor NTFS volumes on windows)

" change wildignore into space separated groups
let g:spaced_wildignore = substitute(substitute(&wildignore,'\*\([?_.A-Za-z]*\)\,',"\\1,","g"),",","\ ","g")
" ==> .aux .out .toc .jpg .bmp .gif .png .jpeg .luac .o .obj .exe .dll .manifest .pyc .pyo .spl .sw .hg .git .svn undodir .hgrc .gitignore
" change wildignore into | delimited groups
let g:piped_wildignore = substitute(substitute(&wildignore,'\*\([?_.A-Za-z]*\)\,',"\\1$,","g"),",",'\\\|',"g")
" ==> .aux$\|.out$\|.toc$\|.jpg$\|.bmp$\|.gif$\|.png$\|.jpeg$\|.luac$\|.o$\|.obj$\|.exe$\|.dll$\|.manifest$\|.pyc$\|.pyo$\|.spl$\|.sw$\|.hg\|.git\|.svn\|undodir\|.hgrc\|.gitignore

if has("win32")|| has("win64")
let g:ctrlp_user_command = ['.git/', 'cd %s && git ls-files', 'es -s %s | findstr /V /l "' . g:spaced_wildignore . '"'] " Windows
else
let g:ctrlp_user_command = ['.git/', 'cd %s && git ls-files', 'locate %s | grep -v "' . g:piped_wildignore . '"'] " MacOSX/Linux
endif