Skip to content

Commit

Permalink
Updated plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
amix committed Aug 2, 2016
1 parent 64a8181 commit 61a22e9
Show file tree
Hide file tree
Showing 39 changed files with 1,356 additions and 766 deletions.
119 changes: 70 additions & 49 deletions sources_non_forked/ctrlp.vim/autoload/ctrlp.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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(...)
Expand Down Expand Up @@ -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, "\\", "/")')
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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()
Expand All @@ -893,17 +895,18 @@ 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'))
en
endf

fu! s:PrtDeleteMRU()
if s:itemtype == 2
if s:curtype() == 'mru'
cal s:delent('ctrlp#mrufiles#remove')
en
endf
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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
Expand All @@ -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')]
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -1649,20 +1655,20 @@ 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]
retu 1
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

Expand Down Expand Up @@ -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>'
Expand Down Expand Up @@ -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
Expand All @@ -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,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -2514,19 +2526,19 @@ 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()
if len(s:Update(s:prompt[0])) == 1
call s:AcceptSelection('e')
call ctrlp#exit()
return 1
endif
en
return 0
endfu

Expand All @@ -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
Expand Down
Loading

0 comments on commit 61a22e9

Please sign in to comment.