parent
3dfb4b444c
commit
62e414de13
@ -720,6 +720,48 @@ Statuslines:~
|
||||
|
||||
For rebuilding the statuslines, see |g:ctrlp_status_func|.
|
||||
|
||||
===============================================================================
|
||||
CUSTOM-CONFIGS *ctrlp-custom-configs*
|
||||
|
||||
* Use |wildignore| for |g:ctrlp_user_command|:
|
||||
>
|
||||
function! s:wig2cmd()
|
||||
" Change wildignore into space or | separated groups
|
||||
" e.g. .aux .out .toc .jpg .bmp .gif
|
||||
" or .aux$\|.out$\|.toc$\|.jpg$\|.bmp$\|.gif$
|
||||
let pats = ['[*\/]*\([?_.0-9A-Za-z]\+\)\([*\/]*\)\(\\\@<!,\|$\)','\\\@<!,']
|
||||
let subs = has('win32') || has('win64') ? ['\1\3', ' '] : ['\1\2\3', '\\|']
|
||||
let expr = substitute(&wig, pats[0], subs[0], 'g')
|
||||
let expr = substitute(expr, pats[1], subs[1], 'g')
|
||||
let expr = substitute(expr, '\\,', ',', 'g')
|
||||
|
||||
" Set the user_command option
|
||||
let g:ctrlp_user_command = has('win32') || has('win64')
|
||||
\ ? 'dir %s /-n /b /s /a-d | findstr /V /l "'.expr.'"'
|
||||
\ : 'find %s -type f | grep -v "'.expr .'"'
|
||||
endfunction
|
||||
|
||||
call s:wig2cmd()
|
||||
<
|
||||
(submitted by Rich Alesi <github.com/ralesi>)
|
||||
|
||||
* Set the working directory to the project’s root, or to the parent directory
|
||||
of the current file if a root can’t be found:
|
||||
>
|
||||
function! s:setcwd()
|
||||
let cph = expand('%:p:h', 1)
|
||||
if match(cph, '\v^<.+>://') >= 0 | retu | en
|
||||
for mkr in ['.git/', '.hg/', '.svn/', '.bzr/', '_darcs/', '.vimprojects']
|
||||
let wd = call('find'.(mkr =~ '/$' ? 'dir' : 'file'), [mkr, cph.';'])
|
||||
if wd != '' | let &acd = 0 | brea | en
|
||||
endfo
|
||||
exe 'lc!' fnameescape(wd == '' ? cph : substitute(wd, mkr.'$', '.', ''))
|
||||
endfunction
|
||||
|
||||
autocmd BufEnter * call s:setcwd()
|
||||
<
|
||||
(requires Vim 7.1.299+)
|
||||
|
||||
===============================================================================
|
||||
CREDITS *ctrlp-credits*
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user