Use more s:var's instead of passing arguments around
This commit is contained in:
parent
448a15c841
commit
dbc40ca3be
@ -318,38 +318,30 @@ fu! ctrlp#buffers()
|
|||||||
\ 'fnamemodify(bufname(v:val), ":.")')
|
\ 'fnamemodify(bufname(v:val), ":.")')
|
||||||
endf
|
endf
|
||||||
" * MatchedItems() {{{1
|
" * MatchedItems() {{{1
|
||||||
fu! s:MatchIt(items, pat, limit, mfunc, ipt, exc)
|
fu! s:MatchIt(items, pat, limit, exc)
|
||||||
let [newitems, id] = [[], 0]
|
let [lines, id] = [[], 0]
|
||||||
for item in a:items
|
for item in a:items
|
||||||
let id += 1
|
let id += 1
|
||||||
try | if !( a:ipt && item == a:exc ) && call(a:mfunc, [item, a:pat]) >= 0
|
try | if !( s:ispath && item == a:exc ) && call(s:mfunc, [item, a:pat]) >= 0
|
||||||
cal add(newitems, item)
|
cal add(lines, item)
|
||||||
en | cat | brea | endt
|
en | cat | brea | endt
|
||||||
if a:limit > 0 && len(newitems) >= a:limit | brea | en
|
if a:limit > 0 && len(lines) >= a:limit | brea | en
|
||||||
endfo
|
endfo
|
||||||
let s:mdata = [s:dyncwd, s:itemtype, s:regexp, s:sublist(a:items, id, -1)]
|
let s:mdata = [s:dyncwd, s:itemtype, s:regexp, s:sublist(a:items, id, -1)]
|
||||||
retu newitems
|
retu lines
|
||||||
endf
|
endf
|
||||||
|
|
||||||
fu! s:MatchedItems(items, str, pat, limit, ipt)
|
fu! s:MatchedItems(items, str, pat, limit)
|
||||||
let [type, mfunc] = [s:type(1), 'match']
|
|
||||||
if s:byfname && a:ipt
|
|
||||||
let mfunc = 's:matchfname'
|
|
||||||
elsei s:itemtype > 2
|
|
||||||
let types = { 'tabs': 's:matchtabs', 'tabe': 's:matchtabe' }
|
|
||||||
if has_key(types, type) | let mfunc = types[type] | en
|
|
||||||
en
|
|
||||||
let exc = exists('s:crfilerel') ? s:crfilerel : ''
|
let exc = exists('s:crfilerel') ? s:crfilerel : ''
|
||||||
let matfunc = 's:MatchIt'
|
|
||||||
let items = s:narrowable() ? s:matched + s:mdata[3] : a:items
|
let items = s:narrowable() ? s:matched + s:mdata[3] : a:items
|
||||||
let argms = [items, a:pat, a:limit, mfunc, a:ipt, exc]
|
|
||||||
if s:matcher != {} && has_key(s:matcher, 'match')
|
if s:matcher != {} && has_key(s:matcher, 'match')
|
||||||
let [matfunc, argms[1], argms[3]] = s:matargs(mfunc, a:str)
|
let argms = [items, a:str, a:limit, s:mmode(), s:ispath, exc, s:regexp]
|
||||||
let argms += [s:regexp]
|
let lines = call(s:matcher['match'], argms)
|
||||||
|
el
|
||||||
|
let lines = s:MatchIt(items, a:pat, a:limit, exc)
|
||||||
en
|
en
|
||||||
let newitems = call(matfunc, argms)
|
let s:matches = len(lines)
|
||||||
let s:matches = len(newitems)
|
retu lines
|
||||||
retu newitems
|
|
||||||
endf
|
endf
|
||||||
|
|
||||||
fu! s:SplitPattern(str)
|
fu! s:SplitPattern(str)
|
||||||
@ -358,7 +350,7 @@ fu! s:SplitPattern(str)
|
|||||||
let str = s:migemo(str)
|
let str = s:migemo(str)
|
||||||
en
|
en
|
||||||
let s:savestr = str
|
let s:savestr = str
|
||||||
if s:regexp || match(str, '\\\(<\|>\)\|[*|]') >= 0
|
if s:regexp
|
||||||
let pat = s:regexfilter(str)
|
let pat = s:regexfilter(str)
|
||||||
el
|
el
|
||||||
let lst = split(str, '\zs')
|
let lst = split(str, '\zs')
|
||||||
@ -381,7 +373,7 @@ fu! s:SplitPattern(str)
|
|||||||
retu escape(pat, '~')
|
retu escape(pat, '~')
|
||||||
endf
|
endf
|
||||||
" * BuildPrompt() {{{1
|
" * BuildPrompt() {{{1
|
||||||
fu! s:Render(lines, pat, ipt)
|
fu! s:Render(lines, pat)
|
||||||
let [&ma, lines, s:height] = [1, a:lines, min([len(a:lines), s:winh])]
|
let [&ma, lines, s:height] = [1, a:lines, min([len(a:lines), s:winh])]
|
||||||
" Setup the match window
|
" Setup the match window
|
||||||
sil! exe '%d _ | res' s:height
|
sil! exe '%d _ | res' s:height
|
||||||
@ -403,7 +395,7 @@ fu! s:Render(lines, pat, ipt)
|
|||||||
let s:matched = copy(lines)
|
let s:matched = copy(lines)
|
||||||
if s:mwreverse | cal reverse(lines) | en
|
if s:mwreverse | cal reverse(lines) | en
|
||||||
let s:lines = copy(lines)
|
let s:lines = copy(lines)
|
||||||
cal map(lines, 's:formatline(v:val, a:ipt)')
|
cal map(lines, 's:formatline(v:val)')
|
||||||
cal setline(1, lines)
|
cal setline(1, lines)
|
||||||
setl noma cul
|
setl noma cul
|
||||||
exe 'keepj norm!' ( s:mwreverse ? 'G' : 'gg' ).'1|'
|
exe 'keepj norm!' ( s:mwreverse ? 'G' : 'gg' ).'1|'
|
||||||
@ -414,7 +406,7 @@ fu! s:Render(lines, pat, ipt)
|
|||||||
en
|
en
|
||||||
" Highlighting
|
" Highlighting
|
||||||
if s:dohighlight()
|
if s:dohighlight()
|
||||||
cal s:highlight(a:pat, s:mathi[1], a:ipt)
|
cal s:highlight(a:pat, s:mathi[1])
|
||||||
en
|
en
|
||||||
endf
|
endf
|
||||||
|
|
||||||
@ -425,10 +417,10 @@ fu! s:Update(str)
|
|||||||
let str = s:sanstail(a:str)
|
let str = s:sanstail(a:str)
|
||||||
" Stop if the string's unchanged
|
" Stop if the string's unchanged
|
||||||
if str == oldstr && !empty(str) && !exists('s:force') | retu | en
|
if str == oldstr && !empty(str) && !exists('s:force') | retu | en
|
||||||
let [pat, ipt] = [s:SplitPattern(str), s:ispathitem()]
|
let pat = s:SplitPattern(str)
|
||||||
let lines = exists('g:ctrlp_nolimit') && empty(str) ? copy(g:ctrlp_lines)
|
let lines = exists('g:ctrlp_nolimit') && empty(str) ? copy(g:ctrlp_lines)
|
||||||
\ : s:MatchedItems(g:ctrlp_lines, str, pat, s:winh, ipt)
|
\ : s:MatchedItems(g:ctrlp_lines, str, pat, s:winh)
|
||||||
cal s:Render(lines, pat, ipt)
|
cal s:Render(lines, pat)
|
||||||
endf
|
endf
|
||||||
|
|
||||||
fu! s:ForceUpdate()
|
fu! s:ForceUpdate()
|
||||||
@ -612,7 +604,7 @@ fu! s:PrtClearCache()
|
|||||||
if s:itemtype == 2
|
if s:itemtype == 2
|
||||||
let g:ctrlp_lines = ctrlp#mrufiles#refresh()
|
let g:ctrlp_lines = ctrlp#mrufiles#refresh()
|
||||||
el
|
el
|
||||||
cal ctrlp#setlines(s:itemtype)
|
cal ctrlp#setlines()
|
||||||
en
|
en
|
||||||
let s:force = 1
|
let s:force = 1
|
||||||
cal s:BuildPrompt(1)
|
cal s:BuildPrompt(1)
|
||||||
@ -708,8 +700,9 @@ fu! s:ToggleRegex()
|
|||||||
endf
|
endf
|
||||||
|
|
||||||
fu! s:ToggleByFname()
|
fu! s:ToggleByFname()
|
||||||
if s:ispathitem()
|
if s:ispath
|
||||||
let s:byfname = s:byfname ? 0 : 1
|
let s:byfname = s:byfname ? 0 : 1
|
||||||
|
let s:mfunc = s:mfunc()
|
||||||
cal s:MapKeys(s:Focus(), 1)
|
cal s:MapKeys(s:Focus(), 1)
|
||||||
cal s:PrtSwitcher()
|
cal s:PrtSwitcher()
|
||||||
en
|
en
|
||||||
@ -717,13 +710,11 @@ endf
|
|||||||
|
|
||||||
fu! s:ToggleType(dir)
|
fu! s:ToggleType(dir)
|
||||||
let ext = exists('g:ctrlp_ext_vars') ? len(g:ctrlp_ext_vars) : 0
|
let ext = exists('g:ctrlp_ext_vars') ? len(g:ctrlp_ext_vars) : 0
|
||||||
let s:itemtype = s:walker(2 + ext, s:itemtype, a:dir)
|
|
||||||
if s:byfname && !s:ispathitem() | let s:byfname = 0 | en
|
|
||||||
unl! g:ctrlp_nolimit
|
unl! g:ctrlp_nolimit
|
||||||
if has('syntax') && exists('g:syntax_on')
|
if has('syntax') && exists('g:syntax_on')
|
||||||
cal ctrlp#syntax()
|
cal ctrlp#syntax()
|
||||||
en
|
en
|
||||||
cal ctrlp#setlines(s:itemtype)
|
cal ctrlp#setlines(s:walker(2 + ext, s:itemtype, a:dir))
|
||||||
cal s:PrtSwitcher()
|
cal s:PrtSwitcher()
|
||||||
endf
|
endf
|
||||||
|
|
||||||
@ -742,7 +733,7 @@ fu! s:SetWD(...)
|
|||||||
let pathmode = a:1
|
let pathmode = a:1
|
||||||
en | en
|
en | en
|
||||||
if a:0 < 2
|
if a:0 < 2
|
||||||
if match(s:crfile, '^\<.\+\>://.*') >= 0 || !pathmode | retu | en
|
if match(s:crfile, '\v^<.+>://') >= 0 || !pathmode | retu | en
|
||||||
if exists('+acd') | let [s:glb_acd, &acd] = [&acd, 0] | en
|
if exists('+acd') | let [s:glb_acd, &acd] = [&acd, 0] | en
|
||||||
cal ctrlp#setdir(s:crfpath)
|
cal ctrlp#setdir(s:crfpath)
|
||||||
en
|
en
|
||||||
@ -777,38 +768,34 @@ fu! ctrlp#acceptfile(mode, line, ...)
|
|||||||
if j2l | cal ctrlp#j2l(j2l) | en
|
if j2l | cal ctrlp#j2l(j2l) | en
|
||||||
el
|
el
|
||||||
" Determine the command to use
|
" Determine the command to use
|
||||||
let useb = bufnr > 0 && getbufvar(bufnr, '&bl') && empty(tail)
|
let useb = bufnr > 0 && buflisted(bufnr) && empty(tail)
|
||||||
let cmd =
|
let cmd =
|
||||||
\ md == 't' || s:splitwin == 1 ? ( useb ? 'tab sb' : 'tabe' ) :
|
\ md == 't' || s:splitwin == 1 ? ( useb ? 'tab sb' : 'tabe' ) :
|
||||||
\ md == 'h' || s:splitwin == 2 ? ( useb ? 'sb' : 'new' ) :
|
\ md == 'h' || s:splitwin == 2 ? ( useb ? 'sb' : 'new' ) :
|
||||||
\ md == 'v' || s:splitwin == 3 ? ( useb ? 'vert sb' : 'vne' ) :
|
\ md == 'v' || s:splitwin == 3 ? ( useb ? 'vert sb' : 'vne' ) :
|
||||||
\ call('ctrlp#normcmd', useb ? ['b', 'bo vert sb'] : ['e'])
|
\ call('ctrlp#normcmd', useb ? ['b', 'bo vert sb'] : ['e'])
|
||||||
" Reset &switchbuf option
|
" Reset &switchbuf option
|
||||||
if useb
|
let [swb, &swb] = [&swb, '']
|
||||||
let [swb, &swb] = [&swb, '']
|
|
||||||
en
|
|
||||||
" Open new window/buffer
|
" Open new window/buffer
|
||||||
let args = [cmd, useb ? bufnr : filpath, a:0 ? ' +'.a:1 : tail, useb, j2l]
|
let args = [cmd, useb ? bufnr : filpath, a:0 ? ' +'.a:1 : tail, useb, j2l]
|
||||||
cal call('s:openfile', args)
|
cal call('s:openfile', args)
|
||||||
if useb
|
let &swb = swb
|
||||||
let &swb = swb
|
|
||||||
en
|
|
||||||
en
|
en
|
||||||
endf
|
endf
|
||||||
|
|
||||||
fu! s:SpecInputs(str)
|
fu! s:SpecInputs(str)
|
||||||
let [str, type] = [a:str, s:type()]
|
let spi = !s:itemtype || s:getextvar('specinput') > 0
|
||||||
if str == '..' && type =~ '\v^(0|dir)$'
|
if a:str == '..' && spi
|
||||||
cal s:parentdir(getcwd())
|
cal s:parentdir(getcwd())
|
||||||
cal ctrlp#setlines(s:itemtype)
|
cal ctrlp#setlines()
|
||||||
cal s:PrtClear()
|
cal s:PrtClear()
|
||||||
retu 1
|
retu 1
|
||||||
elsei str =~ '^[\/]$' && type =~ '\v^(0|dir)$'
|
elsei a:str =~ '^[\/]$' && spi
|
||||||
cal s:SetWD(2, 0)
|
cal s:SetWD(2, 0)
|
||||||
cal ctrlp#setlines(s:itemtype)
|
cal ctrlp#setlines()
|
||||||
cal s:PrtClear()
|
cal s:PrtClear()
|
||||||
retu 1
|
retu 1
|
||||||
elsei str == '?'
|
elsei a:str == '?'
|
||||||
cal s:PrtExit()
|
cal s:PrtExit()
|
||||||
let hlpwin = &columns > 159 ? '| vert res 80' : ''
|
let hlpwin = &columns > 159 ? '| vert res 80' : ''
|
||||||
sil! exe 'bo vert h ctrlp-mappings' hlpwin '| norm! 0'
|
sil! exe 'bo vert h ctrlp-mappings' hlpwin '| norm! 0'
|
||||||
@ -866,7 +853,8 @@ fu! s:CreateNewFile(...)
|
|||||||
endf
|
endf
|
||||||
" * OpenMulti() {{{1
|
" * OpenMulti() {{{1
|
||||||
fu! s:MarkToOpen()
|
fu! s:MarkToOpen()
|
||||||
if s:bufnr <= 0 || s:opmul == '0' || ( s:itemtype > 2 && s:type() !~ 'rts' )
|
if s:bufnr <= 0 || s:opmul == '0'
|
||||||
|
\ || ( s:itemtype > 2 && s:getextvar('opmul') != 1 )
|
||||||
retu
|
retu
|
||||||
en
|
en
|
||||||
let line = !empty(s:lines) ? s:lines[line('.') - 1] : ''
|
let line = !empty(s:lines) ? s:lines[line('.') - 1] : ''
|
||||||
@ -911,7 +899,7 @@ fu! s:OpenMulti()
|
|||||||
let [tail, fnesc] = [s:tail(), exists('*fnameescape') && v:version > 701]
|
let [tail, fnesc] = [s:tail(), exists('*fnameescape') && v:version > 701]
|
||||||
let [emptytail, nwpt] = [empty(tail), exists('g:ctrlp_open_multiple_files')]
|
let [emptytail, nwpt] = [empty(tail), exists('g:ctrlp_open_multiple_files')]
|
||||||
let bufnr = bufnr('^'.mkd[0].'$')
|
let bufnr = bufnr('^'.mkd[0].'$')
|
||||||
let useb = bufnr > 0 && getbufvar(bufnr, '&bl') && emptytail
|
let useb = bufnr > 0 && buflisted(bufnr) && emptytail
|
||||||
let fst = call('ctrlp#normcmd', useb ? ['b', 'bo vert sb'] : ['e'])
|
let fst = call('ctrlp#normcmd', useb ? ['b', 'bo vert sb'] : ['e'])
|
||||||
" Check if it's a replaceable buffer
|
" Check if it's a replaceable buffer
|
||||||
let repabl = ( empty(bufname('%')) && empty(&l:ft) ) || s:nosplit()
|
let repabl = ( empty(bufname('%')) && empty(&l:ft) ) || s:nosplit()
|
||||||
@ -922,7 +910,7 @@ fu! s:OpenMulti()
|
|||||||
" Open the files
|
" Open the files
|
||||||
for va in mkd
|
for va in mkd
|
||||||
let bufnr = bufnr('^'.va.'$')
|
let bufnr = bufnr('^'.va.'$')
|
||||||
let useb = bufnr > 0 && getbufvar(bufnr, '&bl') && emptytail
|
let useb = bufnr > 0 && buflisted(bufnr) && emptytail
|
||||||
let snd = md != '' && has_key(cmds, md) ?
|
let snd = md != '' && has_key(cmds, md) ?
|
||||||
\ ( useb ? cmds[md][0] : cmds[md][1] ) : ( useb ? 'vert sb' : 'vne' )
|
\ ( useb ? cmds[md][0] : cmds[md][1] ) : ( useb ? 'vert sb' : 'vne' )
|
||||||
let cmd = ic == 1 && ( ucr == 'r' || repabl ) ? fst : snd
|
let cmd = ic == 1 && ( ucr == 'r' || repabl ) ? fst : snd
|
||||||
@ -1010,7 +998,7 @@ endf
|
|||||||
|
|
||||||
fu! s:mixedsort(s1, s2)
|
fu! s:mixedsort(s1, s2)
|
||||||
let [cml, cln] = [s:compmatlen(a:s1, a:s2), ctrlp#complen(a:s1, a:s2)]
|
let [cml, cln] = [s:compmatlen(a:s1, a:s2), ctrlp#complen(a:s1, a:s2)]
|
||||||
if s:itemtype < 3 && s:height < 51
|
if s:ispath && s:height < 51
|
||||||
let [par, cfn] = [s:comparent(a:s1, a:s2), s:compfnlen(a:s1, a:s2)]
|
let [par, cfn] = [s:comparent(a:s1, a:s2), s:compfnlen(a:s1, a:s2)]
|
||||||
if s:height < 21
|
if s:height < 21
|
||||||
let [muls, ctm] = s:itemtype == 1
|
let [muls, ctm] = s:itemtype == 1
|
||||||
@ -1076,8 +1064,8 @@ fu! ctrlp#progress(enum)
|
|||||||
redraws
|
redraws
|
||||||
endf
|
endf
|
||||||
" Paths {{{2
|
" Paths {{{2
|
||||||
fu! s:formatline(str, ipt)
|
fu! s:formatline(str)
|
||||||
let cond = a:ipt && ( s:winw - 4 ) < s:strwidth(a:str)
|
let cond = s:ispath && ( s:winw - 4 ) < s:strwidth(a:str)
|
||||||
retu '> '.( cond ? pathshorten(a:str) : a:str )
|
retu '> '.( cond ? pathshorten(a:str) : a:str )
|
||||||
endf
|
endf
|
||||||
|
|
||||||
@ -1227,10 +1215,10 @@ fu! ctrlp#syntax()
|
|||||||
en
|
en
|
||||||
endf
|
endf
|
||||||
|
|
||||||
fu! s:highlight(pat, grp, ipt)
|
fu! s:highlight(pat, grp)
|
||||||
if s:matcher != {} | retu | en
|
if s:matcher != {} | retu | en
|
||||||
cal clearmatches()
|
cal clearmatches()
|
||||||
if !empty(a:pat) && a:ipt
|
if !empty(a:pat) && s:ispath
|
||||||
let pat = s:regexp ? substitute(a:pat, '\\\@<!\^', '^> \\zs', 'g') : a:pat
|
let pat = s:regexp ? substitute(a:pat, '\\\@<!\^', '^> \\zs', 'g') : a:pat
|
||||||
if s:byfname
|
if s:byfname
|
||||||
" Match only filename
|
" Match only filename
|
||||||
@ -1301,7 +1289,16 @@ fu! s:vacantdict(dict)
|
|||||||
endf
|
endf
|
||||||
|
|
||||||
fu! s:sublist(l, s, e)
|
fu! s:sublist(l, s, e)
|
||||||
retu v:version > 701 ? a:l[(a:s):(a:e)] : remove(copy(a:l), a:s, a:e)
|
retu v:version > 701 ? a:l[(a:s):(a:e)] : s:sublist7071(a:l, a:s, a:e)
|
||||||
|
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 id += 1
|
||||||
|
endw
|
||||||
|
retu newlist
|
||||||
endf
|
endf
|
||||||
" Buffers {{{2
|
" Buffers {{{2
|
||||||
fu! s:buftab(bufnr, md)
|
fu! s:buftab(bufnr, md)
|
||||||
@ -1395,6 +1392,13 @@ fu! s:argmaps(md, ...)
|
|||||||
retu a:md
|
retu a:md
|
||||||
endf
|
endf
|
||||||
" Misc {{{2
|
" Misc {{{2
|
||||||
|
fu! s:modevar()
|
||||||
|
let s:matchtype = s:mtype()
|
||||||
|
let s:ispath = s:ispathitem()
|
||||||
|
if !s:ispath | let s:byfname = 0 | en
|
||||||
|
let s:mfunc = s:mfunc()
|
||||||
|
endf
|
||||||
|
|
||||||
fu! s:dosort()
|
fu! s:dosort()
|
||||||
retu s:matcher == {} && ( ( s:itemtype != 2 && !exists('g:ctrlp_nolimit') )
|
retu s:matcher == {} && ( ( s:itemtype != 2 && !exists('g:ctrlp_nolimit') )
|
||||||
\ || s:prompt != ['', '', ''] ) && s:getextvar('sort')
|
\ || s:prompt != ['', '', ''] ) && s:getextvar('sort')
|
||||||
@ -1446,16 +1450,6 @@ endf
|
|||||||
fu! s:walker(m, p, d)
|
fu! s:walker(m, p, d)
|
||||||
retu a:d > 0 ? a:p < a:m ? a:p + a:d : 0 : a:p > 0 ? a:p + a:d : a:m
|
retu a:d > 0 ? a:p < a:m ? a:p + a:d : 0 : a:p > 0 ? a:p + a:d : a:m
|
||||||
endf
|
endf
|
||||||
|
|
||||||
fu! s:matargs(mfunc, str)
|
|
||||||
let match_type = {
|
|
||||||
\ 'match': 'full-line',
|
|
||||||
\ 's:matchfname': 'filename-only',
|
|
||||||
\ 's:matchtabs': 'first-non-tab',
|
|
||||||
\ 's:matchtabe': 'until-last-tab',
|
|
||||||
\ }
|
|
||||||
retu [s:matcher['match'], a:str, match_type[a:mfunc]]
|
|
||||||
endf
|
|
||||||
" Entering & Exiting {{{2
|
" Entering & Exiting {{{2
|
||||||
fu! s:getenv()
|
fu! s:getenv()
|
||||||
let [s:cwd, s:winres] = [getcwd(), [winrestcmd(), &lines, winnr('$')]]
|
let [s:cwd, s:winres] = [getcwd(), [winrestcmd(), &lines, winnr('$')]]
|
||||||
@ -1504,7 +1498,7 @@ fu! s:openfile(cmd, fid, tail, ...)
|
|||||||
cal ctrlp#setlcdir()
|
cal ctrlp#setlcdir()
|
||||||
en
|
en
|
||||||
endf
|
endf
|
||||||
" Matchfuncs {{{2
|
" Matching {{{2
|
||||||
fu! s:matchfname(item, pat)
|
fu! s:matchfname(item, pat)
|
||||||
retu match(split(a:item, s:lash)[-1], a:pat)
|
retu match(split(a:item, s:lash)[-1], a:pat)
|
||||||
endf
|
endf
|
||||||
@ -1516,6 +1510,29 @@ endf
|
|||||||
fu! s:matchtabe(item, pat)
|
fu! s:matchtabe(item, pat)
|
||||||
retu match(split(a:item, '\t\+[^\t]\+$')[0], a:pat)
|
retu match(split(a:item, '\t\+[^\t]\+$')[0], a:pat)
|
||||||
endf
|
endf
|
||||||
|
|
||||||
|
fu! s:mfunc()
|
||||||
|
let mfunc = 'match'
|
||||||
|
if s:byfname && s:ispath
|
||||||
|
let mfunc = 's:matchfname'
|
||||||
|
elsei s:itemtype > 2
|
||||||
|
let matchtypes = { 'tabs': 's:matchtabs', 'tabe': 's:matchtabe' }
|
||||||
|
if has_key(matchtypes, s:matchtype)
|
||||||
|
let mfunc = matchtypes[s:matchtype]
|
||||||
|
en
|
||||||
|
en
|
||||||
|
retu mfunc
|
||||||
|
endf
|
||||||
|
|
||||||
|
fu! s:mmode()
|
||||||
|
let matchmodes = {
|
||||||
|
\ 'match': 'full-line',
|
||||||
|
\ 's:matchfname': 'filename-only',
|
||||||
|
\ 's:matchtabs': 'first-non-tab',
|
||||||
|
\ 's:matchtabe': 'until-last-tab',
|
||||||
|
\ }
|
||||||
|
retu matchmodes[s:mfunc]
|
||||||
|
endf
|
||||||
" Cache {{{2
|
" Cache {{{2
|
||||||
fu! s:writecache(read_cache, cache_file)
|
fu! s:writecache(read_cache, cache_file)
|
||||||
if !a:read_cache && ( ( g:ctrlp_newcache || !filereadable(a:cache_file) )
|
if !a:read_cache && ( ( g:ctrlp_newcache || !filereadable(a:cache_file) )
|
||||||
@ -1542,9 +1559,9 @@ fu! s:insertcache(str)
|
|||||||
cal s:writecache(0, ctrlp#utils#cachefile())
|
cal s:writecache(0, ctrlp#utils#cachefile())
|
||||||
endf
|
endf
|
||||||
" Extensions {{{2
|
" Extensions {{{2
|
||||||
fu! s:type(...)
|
fu! s:mtype()
|
||||||
retu s:itemtype > 2
|
retu s:itemtype > 2
|
||||||
\ ? g:ctrlp_ext_vars[s:itemtype - 3][a:0 ? 'type' : 'sname'] : s:itemtype
|
\ ? g:ctrlp_ext_vars[s:itemtype - 3]['type'] : 'path'
|
||||||
endf
|
endf
|
||||||
|
|
||||||
fu! s:execextvar(key)
|
fu! s:execextvar(key)
|
||||||
@ -1575,13 +1592,14 @@ fu! ctrlp#switchtype(id)
|
|||||||
endf
|
endf
|
||||||
"}}}1
|
"}}}1
|
||||||
" * Initialization {{{1
|
" * Initialization {{{1
|
||||||
fu! ctrlp#setlines(type)
|
fu! ctrlp#setlines(...)
|
||||||
let s:itemtype = a:type
|
if a:0 | let s:itemtype = a:1 | en
|
||||||
|
cal s:modevar()
|
||||||
let types = ['ctrlp#files()', 'ctrlp#buffers()', 'ctrlp#mrufiles#list()']
|
let types = ['ctrlp#files()', 'ctrlp#buffers()', 'ctrlp#mrufiles#list()']
|
||||||
if exists('g:ctrlp_ext_vars')
|
if exists('g:ctrlp_ext_vars')
|
||||||
cal map(copy(g:ctrlp_ext_vars), 'add(types, v:val["init"])')
|
cal map(copy(g:ctrlp_ext_vars), 'add(types, v:val["init"])')
|
||||||
en
|
en
|
||||||
let g:ctrlp_lines = eval(types[a:type])
|
let g:ctrlp_lines = eval(types[s:itemtype])
|
||||||
endf
|
endf
|
||||||
|
|
||||||
fu! ctrlp#init(type, ...)
|
fu! ctrlp#init(type, ...)
|
||||||
|
@ -23,6 +23,7 @@ let s:dir_var = {
|
|||||||
\ 'lname': 'dirs',
|
\ 'lname': 'dirs',
|
||||||
\ 'sname': 'dir',
|
\ 'sname': 'dir',
|
||||||
\ 'type': 'path',
|
\ 'type': 'path',
|
||||||
|
\ 'specinput': 1,
|
||||||
\ }
|
\ }
|
||||||
|
|
||||||
let g:ctrlp_ext_vars = exists('g:ctrlp_ext_vars') && !empty(g:ctrlp_ext_vars)
|
let g:ctrlp_ext_vars = exists('g:ctrlp_ext_vars') && !empty(g:ctrlp_ext_vars)
|
||||||
|
@ -16,6 +16,7 @@ let s:rtscript_var = {
|
|||||||
\ 'lname': 'runtime scripts',
|
\ 'lname': 'runtime scripts',
|
||||||
\ 'sname': 'rts',
|
\ 'sname': 'rts',
|
||||||
\ 'type': 'path',
|
\ 'type': 'path',
|
||||||
|
\ 'opmul': 1,
|
||||||
\ }
|
\ }
|
||||||
|
|
||||||
let g:ctrlp_ext_vars = exists('g:ctrlp_ext_vars') && !empty(g:ctrlp_ext_vars)
|
let g:ctrlp_ext_vars = exists('g:ctrlp_ext_vars') && !empty(g:ctrlp_ext_vars)
|
||||||
|
@ -58,7 +58,7 @@ default: >
|
|||||||
Can be toggled on/off by pressing <c-d> inside the prompt.
|
Can be toggled on/off by pressing <c-d> inside the prompt.
|
||||||
|
|
||||||
*'g:ctrlp_regexp'*
|
*'g:ctrlp_regexp'*
|
||||||
Set this to 1 to set |regexp| search as the default: >
|
Set this to 1 to set regexp search as the default: >
|
||||||
let g:ctrlp_regexp = 0
|
let g:ctrlp_regexp = 0
|
||||||
<
|
<
|
||||||
Can be toggled on/off by pressing <c-r> inside the prompt.
|
Can be toggled on/off by pressing <c-r> inside the prompt.
|
||||||
@ -94,7 +94,7 @@ plugins, help and quickfix. Use this to setup some exceptions: >
|
|||||||
let g:ctrlp_reuse_window = 'netrw'
|
let g:ctrlp_reuse_window = 'netrw'
|
||||||
<
|
<
|
||||||
Acceptable values are partial name, filetype or buftype of the special buffers.
|
Acceptable values are partial name, filetype or buftype of the special buffers.
|
||||||
Use |regexp| to specify the pattern.
|
Use regexp to specify the pattern.
|
||||||
Example: >
|
Example: >
|
||||||
let g:ctrlp_reuse_window = 'netrw\|help\|quickfix'
|
let g:ctrlp_reuse_window = 'netrw\|help\|quickfix'
|
||||||
<
|
<
|
||||||
@ -186,7 +186,7 @@ Specify the number of recently opened files you want CtrlP to remember: >
|
|||||||
<
|
<
|
||||||
|
|
||||||
*'g:ctrlp_mruf_exclude'*
|
*'g:ctrlp_mruf_exclude'*
|
||||||
Files you don’t want CtrlP to remember. Use |regexp| to specify the patterns: >
|
Files you don’t want CtrlP to remember. Use regexp to specify the patterns: >
|
||||||
let g:ctrlp_mruf_exclude = ''
|
let g:ctrlp_mruf_exclude = ''
|
||||||
<
|
<
|
||||||
Examples: >
|
Examples: >
|
||||||
@ -237,7 +237,7 @@ tools on Windows). So be a little mindful of what you put in your |wildignore|.
|
|||||||
|
|
||||||
*'g:ctrlp_custom_ignore'*
|
*'g:ctrlp_custom_ignore'*
|
||||||
In addition to |'wildignore'|, use this for files and directories you want only
|
In addition to |'wildignore'|, use this for files and directories you want only
|
||||||
CtrlP to not show. Use |regexp| to specify the patterns: >
|
CtrlP to not show. Use regexp to specify the patterns: >
|
||||||
let g:ctrlp_custom_ignore = ''
|
let g:ctrlp_custom_ignore = ''
|
||||||
<
|
<
|
||||||
Examples: >
|
Examples: >
|
||||||
@ -375,7 +375,7 @@ path: >
|
|||||||
|
|
||||||
*'g:ctrlp_use_migemo'*
|
*'g:ctrlp_use_migemo'*
|
||||||
Set this to 1 to use Migemo Pattern for Japanese filenames. Migemo Search only
|
Set this to 1 to use Migemo Pattern for Japanese filenames. Migemo Search only
|
||||||
works in |regexp| mode. To split the pattern, separate words with space: >
|
works in regexp mode. To split the pattern, separate words with space: >
|
||||||
let g:ctrlp_use_migemo = 0
|
let g:ctrlp_use_migemo = 0
|
||||||
<
|
<
|
||||||
|
|
||||||
@ -517,8 +517,8 @@ Once inside the prompt:~
|
|||||||
Note: in filename mode, the prompt’s base is '>d>' instead of '>>>'
|
Note: in filename mode, the prompt’s base is '>d>' instead of '>>>'
|
||||||
|
|
||||||
<c-r> *'ctrlp-fullregexp'*
|
<c-r> *'ctrlp-fullregexp'*
|
||||||
Toggle between the string mode and full |regexp| mode.
|
Toggle between the string mode and full regexp mode.
|
||||||
Note: in full |regexp| mode, the prompt’s base is 'r>>' instead of '>>>'
|
Note: in full regexp mode, the prompt’s base is 'r>>' instead of '>>>'
|
||||||
|
|
||||||
See also |input-formats| (guide) and |g:ctrlp_regexp_search| (option).
|
See also |input-formats| (guide) and |g:ctrlp_regexp_search| (option).
|
||||||
|
|
||||||
@ -639,12 +639,13 @@ a) Simple string.
|
|||||||
|
|
||||||
E.g. 'abc' is understood internally as 'a[^a]\{-}b[^b]\{-}c'
|
E.g. 'abc' is understood internally as 'a[^a]\{-}b[^b]\{-}c'
|
||||||
|
|
||||||
b) Vim |regexp|. If the input string contains '*' or '|', it’ll be treated as
|
b) When in regexp mode, the input string’s treated as a Vim’s regexp |pattern|
|
||||||
a Vim’s |regexp| |pattern| without any modification.
|
without any modification.
|
||||||
|
|
||||||
E.g. 'abc\d*efg' will be read as 'abc\d*efg'.
|
E.g. 'abc\d*efg' will be read as 'abc\d*efg'.
|
||||||
|
|
||||||
See also |ctrlp-fullregexp| (keymap) and |g:ctrlp_regexp_search| (option).
|
See |ctrlp-fullregexp| (keymap) and |g:ctrlp_regexp_search| (option) for
|
||||||
|
how to enable regexp mode.
|
||||||
|
|
||||||
c) End the string with a colon ':' followed by a Vim command to execute that
|
c) End the string with a colon ':' followed by a Vim command to execute that
|
||||||
command after opening the file. If you need to use ':' literally, escape it
|
command after opening the file. If you need to use ':' literally, escape it
|
||||||
@ -672,6 +673,8 @@ e) Similarly, submit '/' or '\' to find and go to the project’s root. If the
|
|||||||
project is large, using a VCS listing command to look for files might help
|
project is large, using a VCS listing command to look for files might help
|
||||||
speeding up the intial scan (see |g:ctrlp_user_command| for more details).
|
speeding up the intial scan (see |g:ctrlp_user_command| for more details).
|
||||||
|
|
||||||
|
Note: e) and d) only work in find file mode and directory mode.
|
||||||
|
|
||||||
f) Type the name of a non-existent file and press <c-y> to create it. Mark a
|
f) Type the name of a non-existent file and press <c-y> to create it. Mark a
|
||||||
file with <c-z> to create the new file in the same directory as the marked
|
file with <c-z> to create the new file in the same directory as the marked
|
||||||
file.
|
file.
|
||||||
|
Loading…
Reference in New Issue
Block a user