From e311264c389bc3a7b77f03fac1876af258cfbb0f Mon Sep 17 00:00:00 2001 From: Kien N Date: Wed, 14 Sep 2011 00:17:20 +0700 Subject: [PATCH] update docs on using wildignore --- autoload/ctrlp.vim | 37 ++++++++++++++++++++++++++++++------- doc/ctrlp.txt | 7 +++++-- readme.md | 4 ++-- 3 files changed, 37 insertions(+), 11 deletions(-) diff --git a/autoload/ctrlp.vim b/autoload/ctrlp.vim index 6209e5b..69e6e06 100644 --- a/autoload/ctrlp.vim +++ b/autoload/ctrlp.vim @@ -658,7 +658,7 @@ func! s:MapSpecs(...) \ } for each in keys(prttempdis) if g:ctrlp_mru_files && !has_key(prtmaps, each) - cal extend(prtmaps, {each:prttempdis[each]}) + cal extend(prtmaps, { each : prttempdis[each] }) elseif !g:ctrlp_mru_files cal remove(prtmaps, each) endif @@ -855,8 +855,10 @@ endfunc func! s:compmatlen(s1, s2) " by match length - let mln1 = min(s:matchlens(a:s1, s:compat)) - let mln2 = min(s:matchlens(a:s2, s:compat)) + let lens1 = s:matchlens(a:s1, s:compat) + let lens2 = s:matchlens(a:s2, s:compat) + let mln1 = s:shortest(lens1) + ( s:wordonly(lens1) / 2 ) + let mln2 = s:shortest(lens2) + ( s:wordonly(lens2) / 2 ) retu mln1 == mln2 ? 0 : mln1 > mln2 ? 1 : -1 endfunc @@ -865,20 +867,41 @@ func! s:matchlens(str, pat, ...) retu [] endif let st = exists('a:1') ? a:1 : 0 - let lens = exists('a:2') ? a:2 : [] + let lens = exists('a:2') ? a:2 : {} + let nr = exists('a:3') ? a:3 : 0 if match(a:str, a:pat, st) != -1 let start = match(a:str, a:pat, st) let str = matchstr(a:str, a:pat, st) let len = len(str) let end = matchend(a:str, a:pat, st) - let lens = add(lens, len) - let lens = s:matchlens(a:str, a:pat, end, lens) + let lens = extend(lens, { nr : [len, str] }) + let lens = s:matchlens(a:str, a:pat, end, lens, nr + 1) endif retu lens endfunc +func! s:shortest(lens) + let lns = [] + for nr in keys(a:lens) + cal add(lns, a:lens[nr][0]) + endfor + retu min(lns) +endfunc + +func! s:wordonly(lens) + let lens = a:lens + let minln = s:shortest(lens) + cal filter(lens, 'minln == v:val[0]') + for nr in keys(lens) + if match(lens[nr][1], '\W') >= 0 + retu 1 + endif + endfor + retu 0 +endfunc + func! s:mixedsort(s1, s2) - retu 2 * s:compmatlen(a:s1, a:s2) + s:compare(a:s1, a:s2) + retu 3 * s:compmatlen(a:s1, a:s2) + s:compare(a:s1, a:s2) endfunc "}}} diff --git a/doc/ctrlp.txt b/doc/ctrlp.txt index 2dff838..82eaed0 100644 --- a/doc/ctrlp.txt +++ b/doc/ctrlp.txt @@ -194,9 +194,12 @@ Set this to 0 if you don’t want |CtrlP| to search for dotfiles and dotdirs: > < You can also use |'wildignore'| to exclude anything from the search. e.g. exclude version control directories from the results: > - set wildignore+=.git/*,.hg/*,.svn/* " Linux/MacOSX - set wildignore+=.git\*,.hg\*,.svn\* " Windows + set wildignore+=*/.git/*,*/.hg/*,*/.svn/* " Linux/MacOSX + set wildignore+=.git\*,.hg\*,.svn\* " Windows < +Note: the `*/` in front of each glob is required for the dotfiles search +feature to work correctly along side with |wildignore|. If you’ve disabled +dotfiles search (set |g:ctrlp_dotfiles| to 0), then you can ignore this. *'g:ctrlp_highlight_match'* Use this to enable/disable highlighting of the matched patterns and to specify diff --git a/readme.md b/readme.md index 46416dd..c255330 100644 --- a/readme.md +++ b/readme.md @@ -62,8 +62,8 @@ The parameter is the same (0, 1 or 2): e.g. Just have something like this in your vimrc: ```vim - set wildignore+=.git/*,.hg/*,.svn/* " for Linux/MacOSX - set wildignore+=.git\*,.hg\*,.svn\* " for Windows + set wildignore+=*/.git/*,*/.hg/*,*/.svn/* " for Linux/MacOSX + set wildignore+=.git\*,.hg\*,.svn\* " for Windows ``` _Check [the docs][3] for more mappings, commands and options._