mirror of
https://github.com/amix/vimrc
synced 2025-07-10 03:25:00 +08:00
Updated plugins
This commit is contained in:
@ -414,26 +414,44 @@ fu! ctrlp#files()
|
||||
endf
|
||||
|
||||
fu! s:InitCustomFuncs()
|
||||
if s:igntype == 4 && has_key(s:usrign, 'func-init') && s:usrign['func-init'] != ''
|
||||
if s:igntype == 4 && get(s:usrign, 'func-init', '') != ''
|
||||
exe call(s:usrign['func-init'], [])
|
||||
en
|
||||
endf
|
||||
|
||||
fu! s:CloseCustomFuncs()
|
||||
if s:igntype == 4 && has_key(s:usrign, 'func-close') && s:usrign['func-close'] != ''
|
||||
if s:igntype == 4 && get(s:usrign, 'func-close', '') != ''
|
||||
exe call(s:usrign['func-close'], [])
|
||||
en
|
||||
endf
|
||||
|
||||
fu! s:GlobPath(dirs, depth)
|
||||
let entries = split(globpath(a:dirs, s:glob), "\n")
|
||||
let [dnf, depth] = [ctrlp#dirnfile(entries), a:depth + 1]
|
||||
cal extend(g:ctrlp_allfiles, dnf[1])
|
||||
if !empty(dnf[0]) && !s:maxf(len(g:ctrlp_allfiles)) && depth <= s:maxdepth
|
||||
sil! cal ctrlp#progress(len(g:ctrlp_allfiles), 1)
|
||||
cal s:GlobPath(join(map(dnf[0], 's:fnesc(v:val, "g", ",")'), ','), depth)
|
||||
en
|
||||
endf
|
||||
if has('patch-8.2-0995')
|
||||
fu! s:GlobPath(dirs, depth)
|
||||
let entries = []
|
||||
for e in split(a:dirs, ',')
|
||||
sil let files = readdir(e, '1', {'sort': 'none'})
|
||||
if !s:showhidden | cal filter(files, 'v:val[0] != "."') | en
|
||||
let entries += map(files, 'e.s:lash.v:val')
|
||||
endfo
|
||||
let [dnf, depth] = [ctrlp#dirnfile(entries), a:depth + 1]
|
||||
if &wig != '' | cal filter(dnf[1], 'glob(v:val) != ""') | en
|
||||
let g:ctrlp_allfiles += dnf[1]
|
||||
if !empty(dnf[0]) && !s:maxf(len(g:ctrlp_allfiles)) && depth <= s:maxdepth
|
||||
sil! cal ctrlp#progress(len(g:ctrlp_allfiles), 1)
|
||||
cal s:GlobPath(join(dnf[0], ','), depth)
|
||||
en
|
||||
endf
|
||||
el
|
||||
fu! s:GlobPath(dirs, depth)
|
||||
let entries = split(globpath(a:dirs, s:glob), "\n")
|
||||
let [dnf, depth] = [ctrlp#dirnfile(entries), a:depth + 1]
|
||||
let g:ctrlp_allfiles += dnf[1]
|
||||
if !empty(dnf[0]) && !s:maxf(len(g:ctrlp_allfiles)) && depth <= s:maxdepth
|
||||
sil! cal ctrlp#progress(len(g:ctrlp_allfiles), 1)
|
||||
cal s:GlobPath(join(map(dnf[0], 's:fnesc(v:val, "g", ",")'), ','), depth)
|
||||
en
|
||||
endf
|
||||
en
|
||||
|
||||
fu! s:async_glob_update_progress(timer)
|
||||
let s:must_wait = 0
|
||||
@ -442,26 +460,26 @@ fu! s:async_glob_update_progress(timer)
|
||||
en
|
||||
if exists('s:timer')
|
||||
sil! cal ctrlp#statusline()
|
||||
endif
|
||||
en
|
||||
|
||||
if !exists('s:job')
|
||||
call s:stop_timer_if_exists()
|
||||
endif
|
||||
en
|
||||
endf
|
||||
|
||||
fu! s:async_glob_on_stdout(job, data, ...)
|
||||
if type(a:data) ==# type([])
|
||||
call extend(g:ctrlp_allfiles, filter(a:data, 'v:val !=# ""'))
|
||||
else
|
||||
call add(g:ctrlp_allfiles, a:data)
|
||||
endif
|
||||
let g:ctrlp_allfiles += filter(a:data, 'v:val !=# ""')
|
||||
el
|
||||
let g:ctrlp_allfiles += [a:data]
|
||||
en
|
||||
endf
|
||||
|
||||
fu! s:async_glob_on_exit(...)
|
||||
let s:must_wait = 0
|
||||
if exists('s:job')
|
||||
unlet s:job
|
||||
endif
|
||||
unl s:job
|
||||
en
|
||||
cal s:stop_timer_if_exists()
|
||||
if exists('s:focus') && get(s:, 'setlines_post_ended', 0)
|
||||
sil! cal ctrlp#statusline()
|
||||
@ -477,8 +495,8 @@ endf
|
||||
|
||||
fu! s:stop_timer_if_exists()
|
||||
if exists('s:timer')
|
||||
call timer_stop(s:timer)
|
||||
unlet s:timer
|
||||
cal timer_stop(s:timer)
|
||||
unl s:timer
|
||||
en
|
||||
endf
|
||||
|
||||
@ -486,10 +504,10 @@ fu! s:stop_job_if_exists()
|
||||
if exists('s:job')
|
||||
if !has('nvim')
|
||||
cal job_stop(s:job)
|
||||
else
|
||||
el
|
||||
cal jobstop(s:job)
|
||||
endif
|
||||
unlet s:job
|
||||
en
|
||||
unl s:job
|
||||
en
|
||||
endf
|
||||
|
||||
@ -504,7 +522,7 @@ endf
|
||||
fu! s:UserCmd(lscmd)
|
||||
let [path, lscmd] = [s:dyncwd, a:lscmd]
|
||||
let do_ign =
|
||||
\ type(s:usrcmd) == 4 && has_key(s:usrcmd, 'ignore') && s:usrcmd['ignore']
|
||||
\ type(s:usrcmd) == 4 && get(s:usrcmd, 'ignore', 0)
|
||||
if do_ign && ctrlp#igncwd(s:cwd) | retu | en
|
||||
if exists('+ssl') && &ssl && &shell !~ 'sh'
|
||||
let [ssl, &ssl, path] = [&ssl, 0, tr(path, '/', '\')]
|
||||
@ -526,12 +544,12 @@ fu! s:UserCmd(lscmd)
|
||||
\ 'out_cb': function('s:async_glob_on_stdout'),
|
||||
\ 'exit_cb': function('s:async_glob_on_exit')
|
||||
\ })
|
||||
else
|
||||
el
|
||||
let s:job = jobstart(argv, {
|
||||
\ 'on_stdout': function('s:async_glob_on_stdout'),
|
||||
\ 'on_exit': function('s:async_glob_on_exit')
|
||||
\ })
|
||||
endif
|
||||
en
|
||||
let s:timer = timer_start(250, function('s:async_glob_update_progress'), {'repeat': -1})
|
||||
while s:must_wait
|
||||
sleep 50m
|
||||
@ -570,7 +588,7 @@ fu! s:lsCmd()
|
||||
retu cmd[1]
|
||||
elsei type(cmd) == 4 && ( has_key(cmd, 'types') || has_key(cmd, 'fallback') )
|
||||
let fndroot = []
|
||||
if has_key(cmd, 'types') && cmd['types'] != {}
|
||||
if get(cmd, 'types', {}) != {}
|
||||
let [markrs, cmdtypes] = [[], values(cmd['types'])]
|
||||
for pair in cmdtypes
|
||||
cal add(markrs, pair[0])
|
||||
@ -578,7 +596,7 @@ fu! s:lsCmd()
|
||||
let fndroot = s:findroot(s:dyncwd, markrs, 0, 1)
|
||||
en
|
||||
if fndroot == []
|
||||
retu has_key(cmd, 'fallback') ? cmd['fallback'] : ''
|
||||
retu get(cmd, 'fallback', '')
|
||||
en
|
||||
for pair in cmdtypes
|
||||
if pair[0] == fndroot[0] | brea | en
|
||||
@ -633,7 +651,7 @@ fu! s:MatchIt(items, pat, limit, exc)
|
||||
try
|
||||
if (s:matchcrfile || !( s:ispath && item ==# a:exc )) &&
|
||||
\call(s:mfunc, [item, pat]) >= 0
|
||||
cal add(lines, item)
|
||||
let lines += [item]
|
||||
en
|
||||
cat | brea | endt
|
||||
if a:limit > 0 && len(lines) >= a:limit | brea | en
|
||||
@ -647,12 +665,12 @@ fu! s:MatchedItems(items, pat, limit)
|
||||
let items = s:narrowable() ? s:matched + s:mdata[3] : a:items
|
||||
let matcher = s:getextvar('matcher')
|
||||
if empty(matcher) || type(matcher) != 4 || !has_key(matcher, 'match')
|
||||
unlet matcher
|
||||
unl matcher
|
||||
let matcher = s:matcher
|
||||
en
|
||||
if matcher != {}
|
||||
let argms =
|
||||
\ has_key(matcher, 'arg_type') && matcher['arg_type'] == 'dict' ? [{
|
||||
\ get(matcher, 'arg_type', '') == 'dict' ? [{
|
||||
\ 'items': items,
|
||||
\ 'str': a:pat,
|
||||
\ 'limit': a:limit,
|
||||
@ -723,12 +741,20 @@ fu! s:Render(lines, pat)
|
||||
" Sorting
|
||||
if !s:nosort()
|
||||
let s:compat = s:martcs.pat
|
||||
cal sort(lines, 's:mixedsort')
|
||||
if has('patch-8.1-0')
|
||||
cal sort(lines, function('s:mixedsort2', [s:curtype()]))
|
||||
el
|
||||
cal sort(lines, 's:mixedsort')
|
||||
en
|
||||
unl s:compat
|
||||
en
|
||||
if s:mw_order == 'btt' | cal reverse(lines) | en
|
||||
let s:lines = copy(lines)
|
||||
cal map(lines, s:flfunc)
|
||||
if has('patch-8.1-0') && s:flfunc ==# 's:formatline(v:val)'
|
||||
cal map(lines, function('s:formatline2', [s:curtype()]))
|
||||
el
|
||||
cal map(lines, s:flfunc)
|
||||
en
|
||||
cal setline(1, s:offset(lines, height))
|
||||
cal s:unmarksigns()
|
||||
cal s:remarksigns()
|
||||
@ -755,7 +781,7 @@ fu! s:Update(str)
|
||||
\ : s:MatchedItems(g:ctrlp_lines, pat, s:mw_res)
|
||||
if empty(str) | cal clearmatches() | en
|
||||
cal s:Render(lines, pat)
|
||||
return lines
|
||||
retu lines
|
||||
endf
|
||||
|
||||
fu! s:ForceUpdate()
|
||||
@ -1162,10 +1188,10 @@ fu! s:SetWD(args)
|
||||
\ && exists('s:dyncwd')
|
||||
cal ctrlp#setdir(s:dyncwd) | retu
|
||||
en
|
||||
if has_key(a:args, 'dir') && a:args['dir'] != ''
|
||||
if get(a:args, 'dir', '') != ''
|
||||
cal ctrlp#setdir(a:args['dir']) | retu
|
||||
en
|
||||
let pmodes = has_key(a:args, 'mode') ? a:args['mode'] : s:pathmode
|
||||
let pmodes = get(a:args, 'mode', s:pathmode)
|
||||
let [s:crfilerel, s:dyncwd] = [fnamemodify(s:crfile, ':.'), getcwd()]
|
||||
if (!type(pmodes))
|
||||
let pmodes =
|
||||
@ -1184,7 +1210,7 @@ fu! ctrlp#acceptfile(...)
|
||||
let useb = 0
|
||||
if a:0 == 1 && type(a:1) == 4
|
||||
let [md, line] = [a:1['action'], a:1['line']]
|
||||
let atl = has_key(a:1, 'tail') ? a:1['tail'] : ''
|
||||
let atl = get(a:1, 'tail', '')
|
||||
el
|
||||
let [md, line] = [a:1, a:2]
|
||||
let atl = a:0 > 2 ? a:3 : ''
|
||||
@ -1276,7 +1302,7 @@ fu! s:AcceptSelection(action)
|
||||
" Do something with it
|
||||
if s:openfunc != {} && has_key(s:openfunc, s:ctype)
|
||||
let actfunc = s:openfunc[s:ctype]
|
||||
let type = has_key(s:openfunc, 'arg_type') ? s:openfunc['arg_type'] : 'list'
|
||||
let type = get(s:openfunc, 'arg_type', 'list')
|
||||
el
|
||||
if s:itemtype < len(s:coretypes)
|
||||
let [actfunc, type] = ['ctrlp#acceptfile', 'dict']
|
||||
@ -1351,7 +1377,7 @@ fu! s:MarkToOpen()
|
||||
if exists('s:marked')
|
||||
let vac = s:vacantdict(s:marked)
|
||||
let key = empty(vac) ? len(s:marked) + 1 : vac[0]
|
||||
let s:marked = extend(s:marked, { key : filpath })
|
||||
cal extend(s:marked, { key : filpath })
|
||||
el
|
||||
let [key, s:marked] = [1, { 1 : filpath }]
|
||||
en
|
||||
@ -1460,13 +1486,13 @@ fu! s:OpenNoMarks(md, line)
|
||||
if a:md == 'a'
|
||||
let [s:marked, key] = [{}, 1]
|
||||
for line in s:lines
|
||||
let s:marked = extend(s:marked, { key : fnamemodify(line, ':p') })
|
||||
cal extend(s:marked, { key : fnamemodify(line, ':p') })
|
||||
let key += 1
|
||||
endfo
|
||||
cal s:remarksigns()
|
||||
cal s:BuildPrompt(0)
|
||||
elsei a:md == 'x'
|
||||
let type = has_key(s:openfunc, 'arg_type') ? s:openfunc['arg_type'] : 'dict'
|
||||
let type = get(s:openfunc, 'arg_type', 'dict')
|
||||
let argms = type == 'dict' ? [{ 'action': a:md, 'line': a:line }]
|
||||
\ : [a:md, a:line]
|
||||
cal call(s:openfunc[s:ctype], argms, s:openfunc)
|
||||
@ -1505,15 +1531,15 @@ fu! s:compmreb(...)
|
||||
" By last entered time (bufnr)
|
||||
let [id1, id2] = [index(s:mrbs, a:1), index(s:mrbs, a:2)]
|
||||
if id1 == id2
|
||||
return 0
|
||||
endif
|
||||
retu 0
|
||||
en
|
||||
if id1 < 0
|
||||
return 1
|
||||
endif
|
||||
retu 1
|
||||
en
|
||||
if id2 < 0
|
||||
return -1
|
||||
endif
|
||||
return id1 > id2 ? 1 : -1
|
||||
retu -1
|
||||
en
|
||||
retu id1 > id2 ? 1 : -1
|
||||
endf
|
||||
|
||||
fu! s:compmref(...)
|
||||
@ -1549,7 +1575,7 @@ fu! s:matchlens(str, pat, ...)
|
||||
if nr > 20 | retu {} | en
|
||||
if match(a:str, a:pat, st) >= 0
|
||||
let [mst, mnd] = [matchstr(a:str, a:pat, st), matchend(a:str, a:pat, st)]
|
||||
let lens = extend(lens, { nr : [strlen(mst), mst] })
|
||||
cal extend(lens, { nr : [strlen(mst), mst] })
|
||||
let lens = s:matchlens(a:str, a:pat, mnd, lens, nr + 1)
|
||||
en
|
||||
retu lens
|
||||
@ -1559,6 +1585,32 @@ fu! s:shortest(lens)
|
||||
retu min(map(values(a:lens), 'v:val[0]'))
|
||||
endf
|
||||
|
||||
fu! s:mixedsort2(ct, ...)
|
||||
if a:ct == 'buf'
|
||||
let pat = '[\/]\?\[\d\+\*No Name\]$'
|
||||
if a:1 =~# pat && a:2 =~# pat | retu 0
|
||||
elsei a:1 =~# pat | retu 1
|
||||
elsei a:2 =~# pat | retu -1 | en
|
||||
en
|
||||
let [cln, cml] = [ctrlp#complen(a:1, a:2), s:compmatlen(a:1, a:2)]
|
||||
if s:ispath
|
||||
let ms = []
|
||||
if s:res_count < 21
|
||||
let ms += [s:compfnlen(a:1, a:2)]
|
||||
if a:ct !~ '^\(buf\|mru\)$' | let ms += [s:comptime(a:1, a:2)] | en
|
||||
if !s:itemtype | let ms += [s:comparent(a:1, a:2)] | en
|
||||
en
|
||||
if a:ct =~ '^\(buf\|mru\)$'
|
||||
let ms += [s:compmref(a:1, a:2)]
|
||||
let cln = cml ? cln : 0
|
||||
en
|
||||
let ms += [cml, 0, 0, 0]
|
||||
let mp = call('s:multipliers', ms[:3])
|
||||
retu cln + ms[0] * mp[0] + ms[1] * mp[1] + ms[2] * mp[2] + ms[3] * mp[3]
|
||||
en
|
||||
retu cln + cml * 2
|
||||
endf
|
||||
|
||||
fu! s:mixedsort(...)
|
||||
let ct = s:curtype()
|
||||
if ct == 'buf'
|
||||
@ -1617,7 +1669,7 @@ fu! ctrlp#statusline()
|
||||
\ exists('s:marked') ? ' <'.s:dismrk().'>' : ' <->' : ''
|
||||
if s:status != {}
|
||||
let argms =
|
||||
\ has_key(s:status, 'arg_type') && s:status['arg_type'] == 'dict' ? [{
|
||||
\ get(s:status, 'arg_type', '') == 'dict' ? [{
|
||||
\ 'focus': focus,
|
||||
\ 'byfname': byfname,
|
||||
\ 'regex': s:regexp,
|
||||
@ -1650,7 +1702,7 @@ fu! ctrlp#progress(enum, ...)
|
||||
if has('macunix') || has('mac') | sl 1m | en
|
||||
let txt = a:0 ? '(press ctrl-c to abort)' : ''
|
||||
if s:status != {}
|
||||
let argms = has_key(s:status, 'arg_type') && s:status['arg_type'] == 'dict'
|
||||
let argms = get(s:status, 'arg_type', '') == 'dict'
|
||||
\ ? [{ 'str': a:enum }] : [a:enum]
|
||||
let &l:stl = call(s:status['prog'], argms, s:status)
|
||||
el
|
||||
@ -1687,6 +1739,33 @@ fu! s:formatline(str)
|
||||
retu s:lineprefix.( cond ? s:pathshorten(str) : str )
|
||||
endf
|
||||
|
||||
fu! s:formatline2(ct, key, str)
|
||||
let str = a:str
|
||||
if a:ct == 'buf'
|
||||
let bufnr = s:bufnrfilpath(str)[0]
|
||||
let parts = s:bufparts(bufnr)
|
||||
let str = printf('%'.s:bufnr_width.'s', bufnr)
|
||||
if s:has_conceal && has('syntax_items')
|
||||
let str .= printf(' %-13s %s%-36s',
|
||||
\ '<bi>'.parts[0].'</bi>',
|
||||
\ '<bn>'.parts[1], '{'.parts[2].'}</bn>')
|
||||
if (!empty(s:bufpath_mod))
|
||||
let str .= printf(' %s', '<bp>'.parts[3].'</bp>')
|
||||
en
|
||||
el
|
||||
let str .= printf(' %-5s %-30s',
|
||||
\ parts[0],
|
||||
\ parts[2])
|
||||
if (!empty(s:bufpath_mod))
|
||||
let str .= printf(' %s', parts[3])
|
||||
en
|
||||
en
|
||||
en
|
||||
let cond = a:ct != 'buf' &&s:ispath && ( s:winw - 4 ) < s:strwidth(str)
|
||||
retu s:lineprefix.( cond ? s:pathshorten(str) : str )
|
||||
endf
|
||||
|
||||
|
||||
fu! s:pathshorten(str)
|
||||
retu matchstr(a:str, '^.\{9}').'...'
|
||||
\ .matchstr(a:str, '.\{'.( s:winw - 16 ).'}$')
|
||||
@ -1753,19 +1832,19 @@ fu! ctrlp#dirnfile(entries)
|
||||
if s:igntype >= 0 && s:usrign(each, etype) | con | en
|
||||
if etype == 'dir'
|
||||
if s:showhidden | if each !~ '[\/]\.\{1,2}$'
|
||||
cal add(items[0], each)
|
||||
let items[0] += [each]
|
||||
en | el
|
||||
cal add(items[0], each)
|
||||
let items[0] += [each]
|
||||
en
|
||||
elsei etype == 'link'
|
||||
if s:folsym
|
||||
let isfile = !isdirectory(each)
|
||||
if s:folsym == 2 || !s:samerootsyml(each, isfile, cwd)
|
||||
cal add(items[isfile], each)
|
||||
let items[isfile] += [each]
|
||||
en
|
||||
en
|
||||
elsei etype == 'file'
|
||||
cal add(items[1], each)
|
||||
let items[1] += [each]
|
||||
en
|
||||
endfo
|
||||
retu items
|
||||
@ -1773,17 +1852,12 @@ endf
|
||||
|
||||
fu! s:usrign(item, type)
|
||||
if s:igntype == 1 | retu a:item =~ s:usrign | en
|
||||
if s:igntype == 2
|
||||
if call(s:usrign, [a:item, a:type])
|
||||
retu 1
|
||||
en
|
||||
elsei s:igntype == 4
|
||||
if has_key(s:usrign, a:type) && s:usrign[a:type] != ''
|
||||
\ && a:item =~ s:usrign[a:type]
|
||||
retu 1
|
||||
elsei has_key(s:usrign, 'func') && s:usrign['func'] != ''
|
||||
\ && call(s:usrign['func'], [a:item, a:type])
|
||||
retu 1
|
||||
if s:igntype == 2 | retu call(s:usrign, [a:item, a:type]) | en
|
||||
if s:igntype == 4
|
||||
if get(s:usrign, a:type, '') != ''
|
||||
retu a:item =~ s:usrign[a:type]
|
||||
elsei get(s:usrign, 'func', '') != ''
|
||||
retu call(s:usrign['func'], [a:item, a:type])
|
||||
en
|
||||
en
|
||||
retu 0
|
||||
@ -2024,7 +2098,7 @@ fu! s:ifilter(list, str)
|
||||
for each in a:list
|
||||
try
|
||||
if eval(estr)
|
||||
cal add(rlist, each)
|
||||
let rlist += [each]
|
||||
en
|
||||
cat | con | endt
|
||||
endfo
|
||||
@ -2049,7 +2123,7 @@ endf
|
||||
fu! s:sublist7071(l, s, e)
|
||||
let [newlist, id, ae] = [[], a:s, a:e == -1 ? len(a:l) - 1 : a:e]
|
||||
wh id <= ae
|
||||
cal add(newlist, get(a:l, id))
|
||||
let newlist += [get(a:l, id)]
|
||||
let id += 1
|
||||
endw
|
||||
retu newlist
|
||||
@ -2078,9 +2152,9 @@ endf
|
||||
|
||||
fu! s:isabs(path)
|
||||
if (has('win32') || has('win64'))
|
||||
return a:path =~ '^\([a-zA-Z]:\)\{-}[/\\]'
|
||||
retu a:path =~ '^\([a-zA-Z]:\)\{-}[/\\]'
|
||||
el
|
||||
return a:path =~ '^[/\\]'
|
||||
retu a:path =~ '^[/\\]'
|
||||
en
|
||||
endf
|
||||
|
||||
@ -2292,14 +2366,14 @@ endf
|
||||
fu! s:getinput(...)
|
||||
let [prt, spi] = [s:prompt, ( a:0 ? a:1 : '' )]
|
||||
if s:abbrev != {}
|
||||
let gmd = has_key(s:abbrev, 'gmode') ? s:abbrev['gmode'] : ''
|
||||
let gmd = get(s:abbrev, 'gmode', '')
|
||||
let str = ( gmd =~ 't' && !a:0 ) || spi == 'c' ? prt[0] : join(prt, '')
|
||||
if gmd =~ 't' && gmd =~ 'k' && !a:0 && matchstr(str, '.$') =~ '\k'
|
||||
retu join(prt, '')
|
||||
en
|
||||
let [pf, rz] = [( s:byfname() ? 'f' : 'p' ), ( s:regexp ? 'r' : 'z' )]
|
||||
for dict in s:abbrev['abbrevs']
|
||||
let dmd = has_key(dict, 'mode') ? dict['mode'] : ''
|
||||
let dmd = get(dict, 'mode', '')
|
||||
let pat = escape(dict['pattern'], '~')
|
||||
if ( dmd == '' || ( dmd =~ pf && dmd =~ rz && !a:0 )
|
||||
\ || dmd =~ '['.spi.']' ) && str =~ pat
|
||||
@ -2315,9 +2389,15 @@ fu! s:getinput(...)
|
||||
retu spi == 'c' ? prt[0] : join(prt, '')
|
||||
endf
|
||||
|
||||
fu! s:strwidth(str)
|
||||
retu exists('*strdisplaywidth') ? strdisplaywidth(a:str) : strlen(a:str)
|
||||
endf
|
||||
if exists('*strdisplaywidth')
|
||||
fu! s:strwidth(str)
|
||||
retu strdisplaywidth(a:str)
|
||||
endf
|
||||
el
|
||||
fu! s:strwidth(str)
|
||||
retu strlen(a:str)
|
||||
endf
|
||||
en
|
||||
|
||||
fu! ctrlp#j2l(nr)
|
||||
exe 'norm!' a:nr.'G'
|
||||
@ -2510,7 +2590,7 @@ fu! s:buildpat(lst)
|
||||
endf
|
||||
|
||||
fu! s:curtype()
|
||||
return s:CurTypeName()[1]
|
||||
retu s:CurTypeName()[1]
|
||||
endf
|
||||
|
||||
fu! s:mfunc()
|
||||
@ -2672,9 +2752,9 @@ endf
|
||||
" Returns [lname, sname]
|
||||
fu! s:CurTypeName()
|
||||
if s:itemtype < len(s:coretypes)
|
||||
return filter(copy(s:coretypes), 'v:val[1]==g:ctrlp_types[s:itemtype]')[0]
|
||||
retu filter(copy(s:coretypes), 'v:val[1]==g:ctrlp_types[s:itemtype]')[0]
|
||||
el
|
||||
return [s:getextvar("lname"), s:getextvar('sname')]
|
||||
retu [s:getextvar("lname"), s:getextvar('sname')]
|
||||
en
|
||||
endfu
|
||||
|
||||
@ -2682,15 +2762,15 @@ fu! s:ExitIfSingleCandidate()
|
||||
if len(s:Update(s:prompt[0])) == 1
|
||||
call s:AcceptSelection('e')
|
||||
call ctrlp#exit()
|
||||
return 1
|
||||
retu 1
|
||||
en
|
||||
return 0
|
||||
retu 0
|
||||
endfu
|
||||
|
||||
fu! s:IsBuiltin()
|
||||
let builtins = ['tag', 'dir', 'bft', 'rts', 'bkd', 'lns', 'chs', 'mix', 'udo', 'qfx']
|
||||
let curtype = s:getextvar('sname')
|
||||
return s:itemtype < len(s:coretypes) || index(builtins, curtype) > -1
|
||||
retu s:itemtype < len(s:coretypes) || index(builtins, curtype) > -1
|
||||
endfu
|
||||
|
||||
fu! s:DetectFileType(type, ft)
|
||||
@ -2738,7 +2818,7 @@ fu! ctrlp#init(type, ...)
|
||||
let curName = s:CurTypeName()
|
||||
let shouldExitSingle = index(s:opensingle, curName[0])>=0 || index(s:opensingle, curName[1])>=0
|
||||
if shouldExitSingle && s:ExitIfSingleCandidate()
|
||||
return 0
|
||||
retu 0
|
||||
en
|
||||
cal s:BuildPrompt(1)
|
||||
if s:keyloop | cal s:KeyLoop() | en
|
||||
@ -2753,8 +2833,9 @@ fu! s:NotifySearch()
|
||||
en
|
||||
endf
|
||||
|
||||
fu! ctrlp#update()
|
||||
fu! ctrlp#update(...)
|
||||
cal s:ForceUpdate()
|
||||
if a:0 | cal s:BuildPrompt(a:1) | en
|
||||
endf
|
||||
|
||||
" - Autocmds {{{1
|
||||
|
@ -75,9 +75,9 @@ fu! ctrlp#utils#globpath(...)
|
||||
retu call('globpath', s:wig_cond ? a:000 : a:000[:1])
|
||||
endf
|
||||
|
||||
fu! ctrlp#utils#fnesc(path, type, ...)
|
||||
if exists('*fnameescape')
|
||||
if exists('+ssl')
|
||||
if exists('*fnameescape')
|
||||
if exists('+ssl')
|
||||
fu! ctrlp#utils#fnesc(path, type, ...)
|
||||
if a:type == 'c'
|
||||
let path = escape(a:path, '%#')
|
||||
elsei a:type == 'f'
|
||||
@ -86,11 +86,17 @@ fu! ctrlp#utils#fnesc(path, type, ...)
|
||||
let path = escape(a:path, '?*')
|
||||
en
|
||||
let path = substitute(path, '[', '[[]', 'g')
|
||||
el
|
||||
let path = fnameescape(a:path)
|
||||
en
|
||||
retu a:0 ? escape(path, a:1) : path
|
||||
endf
|
||||
el
|
||||
if exists('+ssl')
|
||||
fu! ctrlp#utils#fnesc(path, type, ...)
|
||||
let path = fnameescape(a:path)
|
||||
retu a:0 ? escape(path, a:1) : path
|
||||
endf
|
||||
en
|
||||
el
|
||||
if exists('+ssl')
|
||||
fu! ctrlp#utils#fnesc(path, type, ...)
|
||||
if a:type == 'c'
|
||||
let path = escape(a:path, '%#')
|
||||
elsei a:type == 'f'
|
||||
@ -99,12 +105,15 @@ fu! ctrlp#utils#fnesc(path, type, ...)
|
||||
let path = escape(a:path, '?*')
|
||||
en
|
||||
let path = substitute(path, '[', '[[]', 'g')
|
||||
el
|
||||
retu a:0 ? escape(path, a:1) : path
|
||||
endf
|
||||
el
|
||||
fu! ctrlp#utils#fnesc(path, type, ...)
|
||||
let path = escape(a:path, " \t\n*?[{`$\\%#'\"|!<")
|
||||
en
|
||||
retu a:0 ? escape(path, a:1) : path
|
||||
endf
|
||||
en
|
||||
retu a:0 ? escape(path, a:1) : path
|
||||
endf
|
||||
en
|
||||
"}}}
|
||||
|
||||
" vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2
|
||||
|
@ -203,7 +203,7 @@ OPTIONS *ctrlp-options*
|
||||
w - 用来修饰r:使用当前工作目录而不是当前文件所在目录进行查找
|
||||
0 或者 <empty> - 禁用这项功能。
|
||||
|
||||
注意 #1: 如果 "a" 或者 "c" 和 "r"一起被包含,当无法找到根目录时使用 "a" 或者
|
||||
注意 #1: 如果 "a" 或者 "c" 和 "r"一起被包含,当无法找到根目录时使用 "a" 或者
|
||||
"c" 的行为(作为备选)。
|
||||
|
||||
注意 #2: 你可以在每个缓冲区内使用 |b:var| 来设置该选项。
|
||||
@ -425,10 +425,12 @@ OPTIONS *ctrlp-options*
|
||||
注意: 当命令使用 |g:ctrlp_user_command| 定义时该选项无效。
|
||||
|
||||
*'g:ctrlp_lazy_update'*
|
||||
设置为1将开启延迟更新特性:只在输入停止一个确定的时间后才更新匹配窗口: >
|
||||
设置为1将或更大可开启延迟更新特性:只在输入停止一个确定的时间后才更新匹配窗口:
|
||||
>
|
||||
let g:ctrlp_lazy_update = 0
|
||||
<
|
||||
如果设置为1,在250毫秒后更新。如果大于1,数字会被作为延迟时间使用。
|
||||
如果设置为1,在250毫秒后更新該值作為默認值。如果大于1,数字会被作为延迟时间使
|
||||
用。
|
||||
|
||||
*'g:ctrlp_default_input'*
|
||||
设置为1将为提示符面板提供当前文件的相对路径作为种子: >
|
||||
@ -1045,7 +1047,7 @@ b) 在正则表达式模式,输入字符串被按照Vim的正则表达式模
|
||||
|
||||
例如: 'abc\d*efg' 会被解读为 'abc\d*efg'。
|
||||
|
||||
如何启用正则表达式模式参见 |ctrlp-fullregexp| (按键绑定)和
|
||||
如何启用正则表达式模式参见 |ctrlp-fullregexp| (按键绑定)和
|
||||
|g:ctrlp_regexp_search| (选项)。
|
||||
|
||||
c) 字符串末尾使用一个冒号':'跟随一个Vim命令来在打开那个文件后执行该命令。如果
|
||||
@ -1255,7 +1257,7 @@ h) 使用?打开帮助文件。
|
||||
这样只会忽略包含 "build" 的目录和包含 "foo.txt" 的文件。不会忽略带
|
||||
有 "build" 的文件或者反过来。
|
||||
|
||||
注意: 如果为了忽略名为 "build" 的目录,而不是『任何』包含 "build"
|
||||
注意: 如果为了忽略名为 "build" 的目录,而不是『任何』包含 "build"
|
||||
的目录,你可以使用下面的正则: ^build$
|
||||
|
||||
- 常见问题:
|
||||
|
@ -437,12 +437,12 @@ Note: does not apply when a command defined with |g:ctrlp_user_command| is
|
||||
being used.
|
||||
|
||||
*'g:ctrlp_lazy_update'*
|
||||
Set this to 1 to enable the lazy-update feature: only update the match window
|
||||
after typing's been stopped for a certain amount of time: >
|
||||
Set this to 1 or bigger to enable the lazy-update feature: only update the
|
||||
match window after typing's been stopped for a certain amount of time: >
|
||||
let g:ctrlp_lazy_update = 0
|
||||
<
|
||||
If is 1, update after 250ms. If bigger than 1, the number will be used as the
|
||||
delay time in milliseconds.
|
||||
If is 1, update after 250ms that value as default tuned. If bigger than 1, the
|
||||
number will be used as the delay time in milliseconds.
|
||||
|
||||
*'g:ctrlp_default_input'*
|
||||
Set this to 1 to enable seeding the prompt with the current file's relative
|
||||
@ -462,7 +462,7 @@ Includes the current file in the match entries: >
|
||||
|
||||
By default, the current file is excluded from the list.
|
||||
|
||||
Note: does not apply when |g:ctrlp_match_func| is used.
|
||||
Note: does not apply when |g:ctrlp_match_func| is used.
|
||||
|
||||
*'g:ctrlp_types'*
|
||||
Set this to list of names to customize core types: >
|
||||
|
Reference in New Issue
Block a user