Skip to content

Commit 0c6f678

Browse files
committed
Merge remote-tracking branch 'origin/master' into redondos/doc_ctrlp_working_path_mode
Conflicts: readme.md
2 parents f04b561 + ae7c96f commit 0c6f678

4 files changed

Lines changed: 1472 additions & 55 deletions

File tree

autoload/ctrlp.vim

Lines changed: 51 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ let [s:pref, s:bpref, s:opts, s:new_opts, s:lc_opts] =
8686
\ 'status_func': ['s:status', {}],
8787
\ 'tabpage_position': ['s:tabpage', 'ac'],
8888
\ 'use_caching': ['s:caching', 1],
89-
\ 'use_migemo': ['s:migemo', 0],
9089
\ 'user_command': ['s:usrcmd', ''],
9190
\ 'working_path_mode': ['s:pathmode', 'ra'],
9291
\ }, {
@@ -283,7 +282,8 @@ fu! s:Open()
283282
sil! exe 'let s:glb_'.ke.' = &'.ke.' | let &'.ke.' = '.string(va)
284283
en | endfo
285284
if s:opmul != '0' && has('signs')
286-
sign define ctrlpmark text=+> texthl=Search
285+
sign define ctrlpmark text=+> texthl=CtrlPMark
286+
hi def link CtrlPMark Search
287287
en
288288
cal s:setupblank()
289289
endf
@@ -387,7 +387,7 @@ fu! s:UserCmd(lscmd)
387387
if exists('+ssl') && &ssl
388388
let [ssl, &ssl, path] = [&ssl, 0, tr(path, '/', '\')]
389389
en
390-
if has('win32') || has('win64')
390+
if (has('win32') || has('win64')) && match(&shellcmdflag, "/") != -1
391391
let lscmd = substitute(lscmd, '\v(^|\&\&\s*)\zscd (/d)@!', 'cd /d ', '')
392392
en
393393
let path = exists('*shellescape') ? shellescape(path) : path
@@ -497,9 +497,6 @@ endf
497497

498498
fu! s:SplitPattern(str)
499499
let str = a:str
500-
if s:migemo && s:regexp && len(str) > 0 && executable('cmigemo')
501-
let str = s:migemo(str)
502-
en
503500
let s:savestr = str
504501
if s:regexp
505502
let pat = s:regexfilter(str)
@@ -959,23 +956,19 @@ fu! s:SetWD(args)
959956
if has_key(a:args, 'dir') && a:args['dir'] != ''
960957
cal ctrlp#setdir(a:args['dir']) | retu
961958
en
962-
let pmode = has_key(a:args, 'mode') ? a:args['mode'] : s:pathmode
959+
let pmodes = has_key(a:args, 'mode') ? a:args['mode'] : s:pathmode
963960
let [s:crfilerel, s:dyncwd] = [fnamemodify(s:crfile, ':.'), getcwd()]
964-
if s:crfile =~ '^.\+://' | retu | en
965-
if pmode =~ 'c' || ( pmode =~ 'a' && stridx(s:crfpath, s:cwd) < 0 )
966-
\ || ( !type(pmode) && pmode )
967-
if exists('+acd') | let [s:glb_acd, &acd] = [&acd, 0] | en
968-
cal ctrlp#setdir(s:crfpath)
969-
en
970-
if pmode =~ 'r' || pmode == 2
971-
let markers = ['.git', '.hg', '.svn', '.bzr', '_darcs']
972-
let spath = pmode =~ 'd' ? s:dyncwd : pmode =~ 'w' ? s:cwd : s:crfpath
973-
if type(s:rmarkers) == 3 && !empty(s:rmarkers)
974-
if s:findroot(spath, s:rmarkers, 0, 0) != [] | retu | en
975-
cal filter(markers, 'index(s:rmarkers, v:val) < 0')
976-
en
977-
cal s:findroot(spath, markers, 0, 0)
978-
en
961+
if (!type(pmodes))
962+
let pmodes =
963+
\ pmodes == 0 ? '' :
964+
\ pmodes == 1 ? 'a' :
965+
\ pmodes == 2 ? 'r' :
966+
\ 'c'
967+
en
968+
let spath = pmodes =~ 'd' ? s:dyncwd : pmodes =~ 'w' ? s:cwd : s:crfpath
969+
for pmode in split(pmodes, '\zs')
970+
if ctrlp#setpathmode(pmode, spath) | retu | en
971+
endfo
979972
endf
980973
" * AcceptSelection() {{{1
981974
fu! ctrlp#acceptfile(...)
@@ -1532,9 +1525,21 @@ fu! ctrlp#dirnfile(entries)
15321525
endf
15331526

15341527
fu! s:usrign(item, type)
1535-
retu s:igntype == 1 ? a:item =~ s:usrign
1536-
\ : s:igntype == 4 && has_key(s:usrign, a:type) && s:usrign[a:type] != ''
1537-
\ ? a:item =~ s:usrign[a:type] : 0
1528+
if s:igntype == 1 | retu a:item =~ s:usrign | end
1529+
if s:igntype == 2
1530+
if call(s:usrign, [a:item, a:type])
1531+
retu 1
1532+
end
1533+
elsei s:igntype == 4
1534+
if has_key(s:usrign, a:type) && s:usrign[a:type] != ''
1535+
\ && a:item =~ s:usrign[a:type]
1536+
retu 1
1537+
elsei has_key(s:usrign, 'func') && s:usrign['func'] != ''
1538+
\ && call(s:usrign['func'], [a:item, a:type])
1539+
retu 1
1540+
end
1541+
end
1542+
retu 0
15381543
endf
15391544

15401545
fu! s:samerootsyml(each, isfile, cwd)
@@ -1586,6 +1591,23 @@ fu! s:findroot(curr, mark, depth, type)
15861591
retu []
15871592
endf
15881593

1594+
fu! ctrlp#setpathmode(pmode, ...)
1595+
if a:pmode == 'c' || ( a:pmode == 'a' && stridx(s:crfpath, s:cwd) < 0 )
1596+
if exists('+acd') | let [s:glb_acd, &acd] = [&acd, 0] | en
1597+
cal ctrlp#setdir(s:crfpath)
1598+
retu 1
1599+
elsei a:pmode == 'r'
1600+
let spath = a:0 ? a:1 : s:crfpath
1601+
let markers = ['.git', '.hg', '.svn', '.bzr', '_darcs']
1602+
if type(s:rmarkers) == 3 && !empty(s:rmarkers)
1603+
if s:findroot(spath, s:rmarkers, 0, 0) != [] | retu 1 | en
1604+
cal filter(markers, 'index(s:rmarkers, v:val) < 0')
1605+
en
1606+
if s:findroot(spath, markers, 0, 0) != [] | retu 1 | en
1607+
en
1608+
retu 0
1609+
endf
1610+
15891611
fu! ctrlp#setdir(path, ...)
15901612
let cmd = a:0 ? a:1 : 'lc!'
15911613
sil! exe cmd s:fnesc(a:path, 'c')
@@ -1946,22 +1968,6 @@ fu! s:getinput(...)
19461968
retu spi == 'c' ? prt[0] : join(prt, '')
19471969
endf
19481970

1949-
fu! s:migemo(str)
1950-
let [str, rtp] = [a:str, s:fnesc(&rtp, 'g')]
1951-
let dict = s:glbpath(rtp, printf("dict/%s/migemo-dict", &enc), 1)
1952-
if !len(dict)
1953-
let dict = s:glbpath(rtp, "dict/migemo-dict", 1)
1954-
en
1955-
if len(dict)
1956-
let [tokens, str, cmd] = [split(str, '\s'), '', 'cmigemo -v -w %s -d %s']
1957-
for token in tokens
1958-
let rtn = system(printf(cmd, shellescape(token), shellescape(dict)))
1959-
let str .= !v:shell_error && strlen(rtn) > 0 ? '.*'.rtn : token
1960-
endfo
1961-
en
1962-
retu str
1963-
endf
1964-
19651971
fu! s:strwidth(str)
19661972
retu exists('*strdisplaywidth') ? strdisplaywidth(a:str) : strlen(a:str)
19671973
endf
@@ -2206,6 +2212,10 @@ fu! ctrlp#getmarkedlist()
22062212
retu exists('s:marked') ? values(s:marked) : []
22072213
endf
22082214

2215+
fu! ctrlp#clearmarkedlist()
2216+
let s:marked = {}
2217+
endf
2218+
22092219
fu! ctrlp#exit()
22102220
cal s:PrtExit()
22112221
endf

0 commit comments

Comments
 (0)