mirror of
https://github.com/amix/vimrc
synced 2025-06-16 01:25:00 +08:00
Updated plugins
This commit is contained in:
@ -97,6 +97,7 @@ let [s:pref, s:bpref, s:opts, s:new_opts, s:lc_opts] =
|
||||
\ 'compare_lim': ['s:compare_lim', 3000],
|
||||
\ 'bufname_mod': ['s:bufname_mod', ':t'],
|
||||
\ 'bufpath_mod': ['s:bufpath_mod', ':~:.:h'],
|
||||
\ 'formatline_func': ['s:flfunc', 's:formatline(v:val)'],
|
||||
\ }, {
|
||||
\ 'open_multiple_files': 's:opmul',
|
||||
\ 'regexp': 's:regexp',
|
||||
@ -203,11 +204,11 @@ let s:hlgrps = {
|
||||
\ }
|
||||
|
||||
" lname, sname of the basic(non-extension) modes
|
||||
let s:coretypes = [
|
||||
let s:coretypes = filter([
|
||||
\ ['files', 'fil'],
|
||||
\ ['buffers', 'buf'],
|
||||
\ ['mru files', 'mru'],
|
||||
\ ]
|
||||
\ ], 'index(g:ctrlp_types, v:val[1])!=-1')
|
||||
|
||||
" Get the options {{{2
|
||||
fu! s:opts(...)
|
||||
@ -439,9 +440,9 @@ fu! s:UserCmd(lscmd)
|
||||
en
|
||||
if has('patch-7.4-597') && !(has('win32') || has('win64'))
|
||||
let g:ctrlp_allfiles = systemlist(printf(lscmd, path))
|
||||
else
|
||||
el
|
||||
let g:ctrlp_allfiles = split(system(printf(lscmd, path)), "\n")
|
||||
end
|
||||
en
|
||||
if exists('+ssl') && exists('ssl')
|
||||
let &ssl = ssl
|
||||
cal map(g:ctrlp_allfiles, 'tr(v:val, "\\", "/")')
|
||||
@ -624,7 +625,7 @@ fu! s:Render(lines, pat)
|
||||
en
|
||||
if s:mw_order == 'btt' | cal reverse(lines) | en
|
||||
let s:lines = copy(lines)
|
||||
cal map(lines, 's:formatline(v:val)')
|
||||
cal map(lines, s:flfunc)
|
||||
cal setline(1, s:offset(lines, height))
|
||||
cal s:unmarksigns()
|
||||
cal s:remarksigns()
|
||||
@ -719,7 +720,7 @@ fu! s:PrtBS()
|
||||
if empty(s:prompt[0]) && s:brfprt != 0
|
||||
cal s:PrtExit()
|
||||
retu
|
||||
endif
|
||||
en
|
||||
unl! s:hstgot
|
||||
let [s:prompt[0], s:matches] = [substitute(s:prompt[0], '.$', '', ''), 1]
|
||||
cal s:BuildPrompt(1)
|
||||
@ -877,12 +878,13 @@ fu! s:PrtFocusMap(char)
|
||||
endf
|
||||
|
||||
fu! s:PrtClearCache()
|
||||
if s:itemtype == 0
|
||||
let ct = s:curtype()
|
||||
if ct == 'fil'
|
||||
cal ctrlp#clr()
|
||||
elsei s:itemtype > 2
|
||||
elsei s:itemtype >= len(s:coretypes)
|
||||
cal ctrlp#clr(s:statypes[s:itemtype][1])
|
||||
en
|
||||
if s:itemtype == 2
|
||||
if ct == 'mru'
|
||||
let g:ctrlp_lines = ctrlp#mrufiles#refresh()
|
||||
el
|
||||
cal ctrlp#setlines()
|
||||
@ -893,9 +895,10 @@ fu! s:PrtClearCache()
|
||||
endf
|
||||
|
||||
fu! s:PrtDeleteEnt()
|
||||
if s:itemtype == 2
|
||||
let ct = s:curtype()
|
||||
if ct == 'mru'
|
||||
cal s:PrtDeleteMRU()
|
||||
elsei s:itemtype == 1
|
||||
elsei ct == 'buf'
|
||||
cal s:delbuf()
|
||||
elsei type(s:getextvar('wipe')) == 1
|
||||
cal s:delent(s:getextvar('wipe'))
|
||||
@ -903,7 +906,7 @@ fu! s:PrtDeleteEnt()
|
||||
endf
|
||||
|
||||
fu! s:PrtDeleteMRU()
|
||||
if s:itemtype == 2
|
||||
if s:curtype() == 'mru'
|
||||
cal s:delent('ctrlp#mrufiles#remove')
|
||||
en
|
||||
endf
|
||||
@ -1011,7 +1014,7 @@ fu! s:ToggleByFname()
|
||||
endf
|
||||
|
||||
fu! s:ToggleType(dir)
|
||||
let max = len(g:ctrlp_ext_vars) + 2
|
||||
let max = len(g:ctrlp_ext_vars) + len(s:coretypes) - 1
|
||||
let next = s:walker(max, s:itemtype, a:dir)
|
||||
cal ctrlp#setlines(next)
|
||||
cal ctrlp#syntax()
|
||||
@ -1151,7 +1154,7 @@ fu! s:AcceptSelection(action)
|
||||
if subm | if s:SpecInputs(str) | retu | en | en
|
||||
" Get the selected line
|
||||
let line = ctrlp#getcline()
|
||||
if !subm && !s:itemtype && line == '' && line('.') > s:offset
|
||||
if !subm && s:curtype() != 'fil' && line == '' && line('.') > s:offset
|
||||
\ && str !~ '\v^(\.\.([\/]\.\.)*[\/]?[.\/]*|/|\\|\?|\@.+)$'
|
||||
cal s:CreateNewFile(md) | retu
|
||||
en
|
||||
@ -1161,7 +1164,7 @@ fu! s:AcceptSelection(action)
|
||||
let actfunc = s:openfunc[s:ctype]
|
||||
let type = has_key(s:openfunc, 'arg_type') ? s:openfunc['arg_type'] : 'list'
|
||||
el
|
||||
if s:itemtype < 3
|
||||
if s:itemtype < len(s:coretypes)
|
||||
let [actfunc, type] = ['ctrlp#acceptfile', 'dict']
|
||||
el
|
||||
let [actfunc, exttype] = [s:getextvar('accept'), s:getextvar('act_farg')]
|
||||
@ -1206,15 +1209,16 @@ fu! s:CreateNewFile(...)
|
||||
endf
|
||||
" * OpenMulti() {{{1
|
||||
fu! s:MarkToOpen()
|
||||
let ct = s:curtype()
|
||||
if s:bufnr <= 0 || s:opmul == '0'
|
||||
\ || ( s:itemtype > 2 && s:getextvar('opmul') != 1 )
|
||||
\ || ( s:itemtype >= len(s:coretypes) && s:getextvar('opmul') != 1 )
|
||||
retu
|
||||
en
|
||||
let line = ctrlp#getcline()
|
||||
|
||||
" Do not allow to mark modified or current buffer
|
||||
let bufnr = s:bufnrfilpath(line)[0]
|
||||
if (s:itemtype == 1 && s:delbufcond(bufnr))
|
||||
if (ct == 'buf' && s:delbufcond(bufnr))
|
||||
retu
|
||||
en
|
||||
|
||||
@ -1247,7 +1251,7 @@ endf
|
||||
fu! s:OpenMulti(...)
|
||||
let has_marked = exists('s:marked')
|
||||
if ( !has_marked && a:0 ) || s:opmul == '0' || !s:ispath
|
||||
\ || ( s:itemtype > 2 && s:getextvar('opmul') != 1 )
|
||||
\ || ( s:itemtype >= len(s:coretypes) && s:getextvar('opmul') != 1 )
|
||||
retu -1
|
||||
en
|
||||
" Get the options
|
||||
@ -1442,7 +1446,8 @@ fu! s:shortest(lens)
|
||||
endf
|
||||
|
||||
fu! s:mixedsort(...)
|
||||
if s:itemtype == 1
|
||||
let ct = s:curtype()
|
||||
if ct == 'buf'
|
||||
let pat = '[\/]\?\[\d\+\*No Name\]$'
|
||||
if a:1 =~# pat && a:2 =~# pat | retu 0
|
||||
elsei a:1 =~# pat | retu 1
|
||||
@ -1453,10 +1458,10 @@ fu! s:mixedsort(...)
|
||||
let ms = []
|
||||
if s:res_count < 21
|
||||
let ms += [s:compfnlen(a:1, a:2)]
|
||||
if s:itemtype !~ '^[12]$' | let ms += [s:comptime(a:1, a:2)] | en
|
||||
if 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 s:itemtype =~ '^[12]$'
|
||||
if ct =~ '^\(buf\|mru\)$'
|
||||
let ms += [s:compmref(a:1, a:2)]
|
||||
let cln = cml ? cln : 0
|
||||
en
|
||||
@ -1540,7 +1545,8 @@ endf
|
||||
" Line formatting {{{3
|
||||
fu! s:formatline(str)
|
||||
let str = a:str
|
||||
if s:itemtype == 1
|
||||
let ct = s:curtype()
|
||||
if ct == 'buf'
|
||||
let bufnr = s:bufnrfilpath(str)[0]
|
||||
let parts = s:bufparts(bufnr)
|
||||
let str = printf('%'.s:bufnr_width.'s', bufnr)
|
||||
@ -1560,7 +1566,7 @@ fu! s:formatline(str)
|
||||
en
|
||||
en
|
||||
en
|
||||
let cond = s:itemtype != 1 &&s:ispath && ( s:winw - 4 ) < s:strwidth(str)
|
||||
let cond = ct != 'buf' &&s:ispath && ( s:winw - 4 ) < s:strwidth(str)
|
||||
retu s:lineprefix.( cond ? s:pathshorten(str) : str )
|
||||
endf
|
||||
|
||||
@ -1615,7 +1621,7 @@ fu! s:lash(...)
|
||||
endf
|
||||
|
||||
fu! s:ispathitem()
|
||||
retu s:itemtype < 3 || ( s:itemtype > 2 && s:getextvar('type') == 'path' )
|
||||
retu s:itemtype < len(s:coretypes) || s:getextvar('type') == 'path'
|
||||
endf
|
||||
|
||||
fu! ctrlp#igncwd(cwd)
|
||||
@ -1649,11 +1655,11 @@ fu! ctrlp#dirnfile(entries)
|
||||
endf
|
||||
|
||||
fu! s:usrign(item, type)
|
||||
if s:igntype == 1 | retu a:item =~ s:usrign | end
|
||||
if s:igntype == 1 | retu a:item =~ s:usrign | en
|
||||
if s:igntype == 2
|
||||
if call(s:usrign, [a:item, a:type])
|
||||
retu 1
|
||||
end
|
||||
en
|
||||
elsei s:igntype == 4
|
||||
if has_key(s:usrign, a:type) && s:usrign[a:type] != ''
|
||||
\ && a:item =~ s:usrign[a:type]
|
||||
@ -1661,8 +1667,8 @@ fu! s:usrign(item, type)
|
||||
elsei has_key(s:usrign, 'func') && s:usrign['func'] != ''
|
||||
\ && call(s:usrign['func'], [a:item, a:type])
|
||||
retu 1
|
||||
end
|
||||
end
|
||||
en
|
||||
en
|
||||
retu 0
|
||||
endf
|
||||
|
||||
@ -1772,7 +1778,7 @@ fu! ctrlp#syntax()
|
||||
exe "sy match CtrlPLinePre '^".escape(get(g:, 'ctrlp_line_prefix', '>'),'^$.*~\')."'"
|
||||
en
|
||||
|
||||
if s:itemtype == 1 && s:has_conceal
|
||||
if s:curtype() == 'buf' && s:has_conceal
|
||||
sy region CtrlPBufferNr matchgroup=CtrlPLinePre start='^>\s\+' end='\s'
|
||||
sy region CtrlPBufferInd concealends matchgroup=Ignore start='<bi>' end='</bi>'
|
||||
sy region CtrlPBufferRegion concealends matchgroup=Ignore start='<bn>' end='</bn>'
|
||||
@ -1810,7 +1816,7 @@ fu! s:highlight(pat, grp)
|
||||
if s:byfname()
|
||||
" Make sure there are no slashes in our match
|
||||
let beginning = beginning.'\([^\/]*$\)\@='
|
||||
end
|
||||
en
|
||||
|
||||
for i in range(len(chars))
|
||||
" Surround our current target letter with \zs and \ze so it only
|
||||
@ -1822,14 +1828,14 @@ fu! s:highlight(pat, grp)
|
||||
if i == 0
|
||||
let charcopy[i] = '\zs'.charcopy[i].'\ze'
|
||||
let middle = join(charcopy, '.\{-}')
|
||||
else
|
||||
el
|
||||
let before = join(charcopy[0:i-1], '.\{-}')
|
||||
let after = join(charcopy[i+1:-1], '.\{-}')
|
||||
let c = charcopy[i]
|
||||
" for abc, match either ab.\{-}c or a.*b.\{-}c in that order
|
||||
let cpat = '\(\zs'.c.'\|'.'.*\zs'.c.'\)\ze.*'
|
||||
let middle = before.cpat.after
|
||||
endif
|
||||
en
|
||||
|
||||
" Now we matchadd for each letter, the basic form being:
|
||||
" ^.*\zsx\ze.*$, but with our pattern we built above for the letter,
|
||||
@ -1956,7 +1962,7 @@ fu! s:isabs(path)
|
||||
endf
|
||||
|
||||
fu! s:bufnrfilpath(line)
|
||||
if s:isabs(a:line) || a:line =~ '^\~[/\\]' || a:line =~ '^\w\+:\/\/'
|
||||
if s:isabs(a:line) || a:line =~ '^\~[/\\]'
|
||||
let filpath = a:line
|
||||
el
|
||||
let filpath = s:dyncwd.s:lash().a:line
|
||||
@ -2140,12 +2146,13 @@ fu! s:modevar()
|
||||
endf
|
||||
|
||||
fu! s:nosort()
|
||||
retu s:matcher != {} || s:nolim == 1 || ( s:itemtype == 2 && s:mrudef )
|
||||
\ || ( s:itemtype =~ '\v^(1|2)$' && s:prompt == ['', '', ''] ) || !s:dosort
|
||||
let ct = s:curtype()
|
||||
retu s:matcher != {} || s:nolim == 1 || ( ct == 'mru' && s:mrudef )
|
||||
\ || ( ct =~ '^\(buf\|mru\)$' && s:prompt == ['', '', ''] ) || !s:dosort
|
||||
endf
|
||||
|
||||
fu! s:byfname()
|
||||
retu s:itemtype != 1 && s:ispath && s:byfname
|
||||
retu s:curtype() != 'buf' && s:ispath && s:byfname
|
||||
endf
|
||||
|
||||
fu! s:narrowable()
|
||||
@ -2374,13 +2381,17 @@ fu! s:buildpat(lst)
|
||||
retu pat
|
||||
endf
|
||||
|
||||
fu! s:curtype()
|
||||
return s:CurTypeName()[1]
|
||||
endf
|
||||
|
||||
fu! s:mfunc()
|
||||
let mfunc = 'match'
|
||||
if s:byfname()
|
||||
let mfunc = 's:matchfname'
|
||||
elsei s:itemtype == 1
|
||||
elsei s:curtype() == 'buf'
|
||||
let mfunc = 's:matchbuf'
|
||||
elsei s:itemtype > 2
|
||||
elsei s:itemtype >= len(s:coretypes)
|
||||
let matchtypes = { 'tabs': 's:matchtabs', 'tabe': 's:matchtabe' }
|
||||
if has_key(matchtypes, s:matchtype)
|
||||
let mfunc = matchtypes[s:matchtype]
|
||||
@ -2439,7 +2450,7 @@ fu! s:insertcache(str)
|
||||
endf
|
||||
" Extensions {{{2
|
||||
fu! s:mtype()
|
||||
retu s:itemtype > 2 ? s:getextvar('type') : 'path'
|
||||
retu s:itemtype >= len(s:coretypes) ? s:getextvar('type') : 'path'
|
||||
endf
|
||||
|
||||
fu! s:execextvar(key)
|
||||
@ -2450,8 +2461,8 @@ fu! s:execextvar(key)
|
||||
endf
|
||||
|
||||
fu! s:getextvar(key)
|
||||
if s:itemtype > 2
|
||||
let vars = g:ctrlp_ext_vars[s:itemtype - 3]
|
||||
if s:itemtype >= len(s:coretypes) && len(g:ctrlp_ext_vars) > 0
|
||||
let vars = g:ctrlp_ext_vars[s:itemtype - len(s:coretypes)]
|
||||
retu has_key(vars, a:key) ? vars[a:key] : -1
|
||||
en
|
||||
retu get(g:, 'ctrlp_' . s:matchtype . '_' . a:key, -1)
|
||||
@ -2505,7 +2516,8 @@ endf
|
||||
fu! ctrlp#setlines(...)
|
||||
if a:0 | let s:itemtype = a:1 | en
|
||||
cal s:modevar()
|
||||
let types = ['ctrlp#files()', 'ctrlp#buffers()', 'ctrlp#mrufiles#list()']
|
||||
let inits = {'fil': 'ctrlp#files()', 'buf': 'ctrlp#buffers()', 'mru': 'ctrlp#mrufiles#list()'}
|
||||
let types = map(copy(g:ctrlp_types), 'inits[v:val]')
|
||||
if !empty(g:ctrlp_ext_vars)
|
||||
cal map(copy(g:ctrlp_ext_vars), 'add(types, v:val["init"])')
|
||||
en
|
||||
@ -2514,11 +2526,11 @@ endf
|
||||
|
||||
" Returns [lname, sname]
|
||||
fu! s:CurTypeName()
|
||||
if s:itemtype < 3
|
||||
return s:coretypes[s:itemtype]
|
||||
else
|
||||
if s:itemtype < len(s:coretypes)
|
||||
return filter(copy(s:coretypes), 'v:val[1]==g:ctrlp_types[s:itemtype]')[0]
|
||||
el
|
||||
return [s:getextvar("lname"), s:getextvar('sname')]
|
||||
endif
|
||||
en
|
||||
endfu
|
||||
|
||||
fu! s:ExitIfSingleCandidate()
|
||||
@ -2526,7 +2538,7 @@ fu! s:ExitIfSingleCandidate()
|
||||
call s:AcceptSelection('e')
|
||||
call ctrlp#exit()
|
||||
return 1
|
||||
endif
|
||||
en
|
||||
return 0
|
||||
endfu
|
||||
|
||||
@ -2539,14 +2551,23 @@ fu! ctrlp#init(type, ...)
|
||||
cal s:SetWD(a:0 ? a:1 : {})
|
||||
cal s:MapNorms()
|
||||
cal s:MapSpecs()
|
||||
cal ctrlp#setlines(s:settype(a:type))
|
||||
if type(a:type) == 0
|
||||
let type = a:type
|
||||
el
|
||||
let type = index(g:ctrlp_types, a:type)
|
||||
if type == -1
|
||||
call ctrlp#exit()
|
||||
retu
|
||||
en
|
||||
en
|
||||
cal ctrlp#setlines(s:settype(type))
|
||||
cal ctrlp#syntax()
|
||||
cal s:SetDefTxt()
|
||||
let curName = s:CurTypeName()
|
||||
let shouldExitSingle = index(s:opensingle, curName[0])>=0 || index(s:opensingle, curName[1])>=0
|
||||
if shouldExitSingle && s:ExitIfSingleCandidate()
|
||||
return 0
|
||||
endif
|
||||
en
|
||||
cal s:BuildPrompt(1)
|
||||
if s:keyloop | cal s:KeyLoop() | en
|
||||
return 1
|
||||
|
Reference in New Issue
Block a user