Resolve a few issues
* Use :buffer commands when opening already opened files, all modes. Refs #97. * Temporarily enable full-path if input has '/' or '\'. Close #98. * Ignore possible empty return strings (from malformed tags). Close #99. * Fix an incorrect cwd bug when opening multiple buffers with <c-o>. Introduced by f1c2b7a. Refs #108. * Default keymap can be disabled with `let g:ctrlp_map = ''`. Refs #103. * Remove duplicate rts entries. Close #107.
This commit is contained in:
parent
2797fb8e9a
commit
e7b08a3223
@ -27,7 +27,6 @@ fu! s:opts()
|
|||||||
\ 'g:ctrlp_max_files': ['s:maxfiles', 20000],
|
\ 'g:ctrlp_max_files': ['s:maxfiles', 20000],
|
||||||
\ 'g:ctrlp_max_height': ['s:mxheight', 10],
|
\ 'g:ctrlp_max_height': ['s:mxheight', 10],
|
||||||
\ 'g:ctrlp_max_history': ['s:maxhst', hst],
|
\ 'g:ctrlp_max_history': ['s:maxhst', hst],
|
||||||
\ 'g:ctrlp_mruf_relative': ['s:relate', 0],
|
|
||||||
\ 'g:ctrlp_open_multi': ['s:opmul', '1v'],
|
\ 'g:ctrlp_open_multi': ['s:opmul', '1v'],
|
||||||
\ 'g:ctrlp_open_new_file': ['s:newfop', 'v'],
|
\ 'g:ctrlp_open_new_file': ['s:newfop', 'v'],
|
||||||
\ 'g:ctrlp_prompt_mappings': ['s:urprtmaps', 0],
|
\ 'g:ctrlp_prompt_mappings': ['s:urprtmaps', 0],
|
||||||
@ -290,7 +289,7 @@ fu! s:MatchIt(items, pat, limit, mfunc)
|
|||||||
retu newitems
|
retu newitems
|
||||||
endf
|
endf
|
||||||
|
|
||||||
fu! s:MatchedItems(items, pats, limit)
|
fu! s:MatchedItems(items, pats, limit, bfn)
|
||||||
let [items, pats, limit] = [a:items, a:pats, a:limit]
|
let [items, pats, limit] = [a:items, a:pats, a:limit]
|
||||||
" If items is longer than s:mltipats_lim, use only the last pattern
|
" If items is longer than s:mltipats_lim, use only the last pattern
|
||||||
if len(items) >= s:mltipats_lim || ( exists('s:height') && s:height > 20 )
|
if len(items) >= s:mltipats_lim || ( exists('s:height') && s:height > 20 )
|
||||||
@ -299,7 +298,7 @@ fu! s:MatchedItems(items, pats, limit)
|
|||||||
cal map(pats, 'substitute(v:val, "\\\~", "\\\\\\~", "g")')
|
cal map(pats, 'substitute(v:val, "\\\~", "\\\\\\~", "g")')
|
||||||
if !s:regexp | cal map(pats, 'escape(v:val, ".")') | en
|
if !s:regexp | cal map(pats, 'escape(v:val, ".")') | en
|
||||||
let [type, ipt, mfunc] = [s:type(1), s:ispathitem(), 'match']
|
let [type, ipt, mfunc] = [s:type(1), s:ispathitem(), 'match']
|
||||||
if s:byfname && ipt
|
if s:byfname && ipt && a:bfn
|
||||||
let mfunc = 's:matchfname'
|
let mfunc = 's:matchfname'
|
||||||
elsei s:itemtype > 2
|
elsei s:itemtype > 2
|
||||||
let types = { 'tabs': 's:matchtabs', 'tabe': 's:matchtabe' }
|
let types = { 'tabs': 's:matchtabs', 'tabe': 's:matchtabe' }
|
||||||
@ -353,7 +352,7 @@ fu! s:SplitPattern(str, ...) "{{{1
|
|||||||
retu newpats
|
retu newpats
|
||||||
endf
|
endf
|
||||||
" * BuildPrompt() {{{1
|
" * BuildPrompt() {{{1
|
||||||
fu! s:Render(lines, pat)
|
fu! s:Render(lines, pat, bfn)
|
||||||
let lines = a:lines
|
let lines = a:lines
|
||||||
" Setup the match window
|
" Setup the match window
|
||||||
let s:height = min([len(lines), s:mxheight])
|
let s:height = min([len(lines), s:mxheight])
|
||||||
@ -387,7 +386,7 @@ fu! s:Render(lines, pat)
|
|||||||
en
|
en
|
||||||
" Highlighting
|
" Highlighting
|
||||||
if s:dohighlight()
|
if s:dohighlight()
|
||||||
cal s:highlight(a:pat, empty(s:mathi[1]) ? 'Identifier' : s:mathi[1])
|
cal s:highlight(a:pat, s:mathi[1] == '' ? 'Identifier' : s:mathi[1], a:bfn)
|
||||||
en
|
en
|
||||||
endf
|
endf
|
||||||
|
|
||||||
@ -403,9 +402,10 @@ fu! s:Update(str)
|
|||||||
if notail == oldstr && !empty(notail) && !exists('s:force')
|
if notail == oldstr && !empty(notail) && !exists('s:force')
|
||||||
retu
|
retu
|
||||||
en
|
en
|
||||||
|
let bfn = notail != '' && match(notail, '\v/|\\:@!') < 0
|
||||||
let lines = exists('g:ctrlp_nolimit') && empty(notail) ? copy(g:ctrlp_lines)
|
let lines = exists('g:ctrlp_nolimit') && empty(notail) ? copy(g:ctrlp_lines)
|
||||||
\ : s:MatchedItems(g:ctrlp_lines, copy(pats), s:mxheight)
|
\ : s:MatchedItems(g:ctrlp_lines, copy(pats), s:mxheight, bfn)
|
||||||
cal s:Render(lines, pats[-1])
|
cal s:Render(lines, pats[-1], bfn)
|
||||||
endf
|
endf
|
||||||
|
|
||||||
fu! s:ForceUpdate()
|
fu! s:ForceUpdate()
|
||||||
@ -678,7 +678,7 @@ fu! s:ToggleType(dir)
|
|||||||
unl! g:ctrlp_nolimit
|
unl! g:ctrlp_nolimit
|
||||||
cal s:SetLines(s:itemtype)
|
cal s:SetLines(s:itemtype)
|
||||||
cal s:PrtSwitcher()
|
cal s:PrtSwitcher()
|
||||||
if s:itemtype < 3 && has('syntax') && exists('g:syntax_on')
|
if has('syntax') && exists('g:syntax_on')
|
||||||
cal s:syntax()
|
cal s:syntax()
|
||||||
en
|
en
|
||||||
endf
|
endf
|
||||||
@ -713,15 +713,13 @@ fu! s:SetWD(...) "{{{1
|
|||||||
endf
|
endf
|
||||||
" * AcceptSelection() {{{1
|
" * AcceptSelection() {{{1
|
||||||
fu! ctrlp#acceptfile(mode, matchstr, ...)
|
fu! ctrlp#acceptfile(mode, matchstr, ...)
|
||||||
let [md, matchstr] = [a:mode, a:matchstr]
|
let [md, filpath] = [a:mode, fnamemodify(a:matchstr, ':p')]
|
||||||
" Get the full path
|
|
||||||
let filpath = s:nocwd() ? getcwd().s:lash().matchstr : matchstr
|
|
||||||
cal s:PrtExit()
|
cal s:PrtExit()
|
||||||
let bufnum = bufnr(filpath)
|
let [bufnr, tail] = [bufnr(filpath), s:tail()]
|
||||||
if s:jmptobuf && bufnum > 0 && md =~ 'e\|t'
|
if s:jmptobuf && bufnr > 0 && md =~ 'e\|t'
|
||||||
let [jmpb, bufwinnr] = [1, bufwinnr(bufnum)]
|
let [jmpb, bufwinnr] = [1, bufwinnr(bufnr)]
|
||||||
let buftab = s:jmptobuf > 1 ? s:buftab(bufnum, md) : [0, 0]
|
let buftab = s:jmptobuf > 1 ? s:buftab(bufnr, md) : [0, 0]
|
||||||
let j2l = a:0 ? a:1 : str2nr(matchstr(s:tail(), '^ +\D*\zs\d\+\ze\D*'))
|
let j2l = a:0 ? a:1 : str2nr(matchstr(tail, '^ +\D*\zs\d\+\ze\D*'))
|
||||||
en
|
en
|
||||||
" Switch to existing buffer or open new one
|
" Switch to existing buffer or open new one
|
||||||
if exists('jmpb') && bufwinnr > 0 && md != 't'
|
if exists('jmpb') && bufwinnr > 0 && md != 't'
|
||||||
@ -733,11 +731,18 @@ fu! ctrlp#acceptfile(mode, matchstr, ...)
|
|||||||
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 cmd = md == 't' || s:splitwin == 1 ? 'tabe'
|
let useb = bufnr > 0 && empty(tail)
|
||||||
\ : md == 'h' || s:splitwin == 2 ? 'new'
|
let cmd =
|
||||||
\ : md == 'v' || s:splitwin == 3 ? 'vne' : ctrlp#normcmd('e')
|
\ md == 't' || s:splitwin == 1 ? ( useb ? 'tab sb' : 'tabe' ) :
|
||||||
|
\ md == 'h' || s:splitwin == 2 ? ( useb ? 'sb' : 'new' ) :
|
||||||
|
\ md == 'v' || s:splitwin == 3 ? ( useb ? 'vert sb' : 'vne' ) :
|
||||||
|
\ call('ctrlp#normcmd', useb ? ['b', 'bo vert sb'] : ['e'])
|
||||||
|
" Reset &switchbuf option
|
||||||
|
let [swb, &swb] = [&swb, '']
|
||||||
" Open new window/buffer
|
" Open new window/buffer
|
||||||
cal call('s:openfile', a:0 ? [cmd, filpath, ' +'.a:1] : [cmd, filpath])
|
let fid = useb ? bufnr : filpath
|
||||||
|
cal call('s:openfile', a:0 ? [cmd, fid, ' +'.a:1] : [cmd, fid])
|
||||||
|
let &swb = swb
|
||||||
en
|
en
|
||||||
endf
|
endf
|
||||||
|
|
||||||
@ -799,11 +804,11 @@ fu! s:CreateNewFile(...) "{{{1
|
|||||||
let str = ctrlp#rmbasedir([pah.s:lash(pah).str])[0]
|
let str = ctrlp#rmbasedir([pah.s:lash(pah).str])[0]
|
||||||
en
|
en
|
||||||
en
|
en
|
||||||
if len(arr) | if isdirectory(s:createparentdirs(arr))
|
if len(arr) | if isdirectory(ctrlp#utils#createpath(arr))
|
||||||
let optyp = str | en | el | let optyp = fname
|
let optyp = str | en | el | let optyp = fname
|
||||||
en
|
en
|
||||||
if !exists('optyp') | retu | en
|
if !exists('optyp') | retu | en
|
||||||
let filpath = getcwd().s:lash().optyp
|
let filpath = fnamemodify(optyp, ':p')
|
||||||
cal s:insertcache(str)
|
cal s:insertcache(str)
|
||||||
cal s:PrtExit()
|
cal s:PrtExit()
|
||||||
let cmd = md == 'r' ? ctrlp#normcmd('e') :
|
let cmd = md == 'r' ? ctrlp#normcmd('e') :
|
||||||
@ -821,7 +826,7 @@ fu! s:MarkToOpen()
|
|||||||
en
|
en
|
||||||
let matchstr = matchstr(getline('.'), '^> \zs.\+\ze\t*$')
|
let matchstr = matchstr(getline('.'), '^> \zs.\+\ze\t*$')
|
||||||
if empty(matchstr) | retu | en
|
if empty(matchstr) | retu | en
|
||||||
let filpath = s:nocwd() ? getcwd().s:lash().matchstr : matchstr
|
let filpath = fnamemodify(matchstr, ':p')
|
||||||
if exists('s:marked') && s:dictindex(s:marked, filpath) > 0
|
if exists('s:marked') && s:dictindex(s:marked, filpath) > 0
|
||||||
" Unmark and remove the file from s:marked
|
" Unmark and remove the file from s:marked
|
||||||
let key = s:dictindex(s:marked, filpath)
|
let key = s:dictindex(s:marked, filpath)
|
||||||
@ -854,23 +859,32 @@ fu! s:OpenMulti()
|
|||||||
let md = s:argmaps(md)
|
let md = s:argmaps(md)
|
||||||
if md == 'cancel' | retu | en
|
if md == 'cancel' | retu | en
|
||||||
en
|
en
|
||||||
let mkd = s:marked
|
let mkd = values(s:marked)
|
||||||
cal s:sanstail(join(s:prompt, ''))
|
cal s:sanstail(join(s:prompt, ''))
|
||||||
cal s:PrtExit()
|
cal s:PrtExit()
|
||||||
" Move the cursor to a reusable window
|
" Move the cursor to a reusable window
|
||||||
let fst = ctrlp#normcmd('e')
|
let emptytail = empty(s:tail())
|
||||||
|
let useb = bufnr(mkd[0]) > 0 && emptytail
|
||||||
|
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()
|
||||||
" Pick a command for the rest of the files
|
" Commands for the rest of the files
|
||||||
let [ic, cmds] = [1, { 'v': 'vne', 'h': 'new', 't': 'tabe' }]
|
let [ic, cmds] = [1, { 'v': ['vert sb', 'vne'], 'h': ['sb', 'new'],
|
||||||
let snd = md != '' && has_key(cmds, md) ? cmds[md] : 'vne'
|
\ 't': ['tab sb', 'tabe'] }]
|
||||||
|
let [swb, &swb] = [&swb, '']
|
||||||
" Open the files
|
" Open the files
|
||||||
for va in values(mkd)
|
for va in mkd
|
||||||
cal s:openfile(ic == 1 && ( ucr == 'r' || repabl ) ? fst : snd, va)
|
let bufnr = bufnr(va)
|
||||||
|
let useb = bufnr > 0 && emptytail
|
||||||
|
let snd = md != '' && has_key(cmds, md)
|
||||||
|
\ ? ( useb ? cmds[md][0] : cmds[md][1] ) : ( useb ? 'vert sb' : 'vne' )
|
||||||
|
let fid = useb ? bufnr : va
|
||||||
|
cal s:openfile(ic == 1 && ( ucr == 'r' || repabl ) ? fst : snd, fid)
|
||||||
if ( nr != '' && nr > 1 && nr < ic ) || ( nr == '' && ic > 1 )
|
if ( nr != '' && nr > 1 && nr < ic ) || ( nr == '' && ic > 1 )
|
||||||
sil! hid clo! | el | let ic += 1
|
sil! hid clo! | el | let ic += 1
|
||||||
en
|
en
|
||||||
endfo
|
endfo
|
||||||
|
let &swb = swb
|
||||||
endf
|
endf
|
||||||
" ** Helper functions {{{1
|
" ** Helper functions {{{1
|
||||||
" Sorting {{{2
|
" Sorting {{{2
|
||||||
@ -895,9 +909,8 @@ endf
|
|||||||
|
|
||||||
fu! s:comparent(s1, s2)
|
fu! s:comparent(s1, s2)
|
||||||
" By same parent dir
|
" By same parent dir
|
||||||
let cwd = getcwd()
|
if match(s:crfpath, escape(getcwd(), '.^$*\')) >= 0
|
||||||
if match(s:crfpath, escape(cwd, '.^$*\')) >= 0
|
let [as1, as2] = [fnamemodify(a:s1, ':p'), fnamemodify(a:s2, ':p')]
|
||||||
let [as1, as2] = [cwd.s:lash().a:s1, cwd.s:lash().a:s2]
|
|
||||||
let [loc1, loc2] = [s:getparent(as1), s:getparent(as2)]
|
let [loc1, loc2] = [s:getparent(as1), s:getparent(as2)]
|
||||||
if loc1 == s:crfpath && loc2 != s:crfpath | retu -1 | en
|
if loc1 == s:crfpath && loc2 != s:crfpath | retu -1 | en
|
||||||
if loc2 == s:crfpath && loc1 != s:crfpath | retu 1 | en
|
if loc2 == s:crfpath && loc1 != s:crfpath | retu 1 | en
|
||||||
@ -1074,14 +1087,6 @@ fu! s:getparent(item)
|
|||||||
retu parent
|
retu parent
|
||||||
endf
|
endf
|
||||||
|
|
||||||
fu! s:createparentdirs(arr)
|
|
||||||
for each in a:arr
|
|
||||||
let curr = exists('curr') ? curr.s:lash(curr).each : each
|
|
||||||
cal ctrlp#utils#mkdir(curr)
|
|
||||||
endfo
|
|
||||||
retu curr
|
|
||||||
endf
|
|
||||||
|
|
||||||
fu! s:findroot(curr, mark, depth, type)
|
fu! s:findroot(curr, mark, depth, type)
|
||||||
let [depth, notfound] = [a:depth + 1, empty(s:glbpath(a:curr, a:mark, 1))]
|
let [depth, notfound] = [a:depth + 1, empty(s:glbpath(a:curr, a:mark, 1))]
|
||||||
if !notfound || depth > s:maxdepth
|
if !notfound || depth > s:maxdepth
|
||||||
@ -1122,13 +1127,13 @@ fu! s:syntax()
|
|||||||
hi CtrlPLineMarker guifg=bg
|
hi CtrlPLineMarker guifg=bg
|
||||||
endf
|
endf
|
||||||
|
|
||||||
fu! s:highlight(pat, grp)
|
fu! s:highlight(pat, grp, bfn)
|
||||||
cal clearmatches()
|
cal clearmatches()
|
||||||
if !empty(a:pat) && s:ispathitem()
|
if !empty(a:pat) && s:ispathitem()
|
||||||
let pat = substitute(a:pat, '\~', '\\~', 'g')
|
let pat = substitute(a:pat, '\~', '\\~', 'g')
|
||||||
if !s:regexp | let pat = escape(pat, '.') | en
|
if !s:regexp | let pat = escape(pat, '.') | en
|
||||||
" Match only filename
|
" Match only filename
|
||||||
if s:byfname
|
if s:byfname && a:bfn
|
||||||
let pat = substitute(pat, '\[\^\(.\{-}\)\]\\{-}', '[^\\/\1]\\{-}', 'g')
|
let pat = substitute(pat, '\[\^\(.\{-}\)\]\\{-}', '[^\\/\1]\\{-}', 'g')
|
||||||
let pat = substitute(pat, '$', '\\ze[^\\/]*$', 'g')
|
let pat = substitute(pat, '$', '\\ze[^\\/]*$', 'g')
|
||||||
en
|
en
|
||||||
@ -1170,10 +1175,8 @@ endf
|
|||||||
|
|
||||||
fu! s:remarksigns()
|
fu! s:remarksigns()
|
||||||
if !s:dosigns() | retu | en
|
if !s:dosigns() | retu | en
|
||||||
let [nls, head] = [s:matched, s:itemtype ? '' : getcwd().s:lash()]
|
for ic in range(1, len(s:matched))
|
||||||
for ic in range(1, len(nls))
|
let key = s:dictindex(s:marked, fnamemodify(s:matched[ic - 1], ':p'))
|
||||||
let filpath = head.nls[ic - 1]
|
|
||||||
let key = s:dictindex(s:marked, filpath)
|
|
||||||
if key > 0
|
if key > 0
|
||||||
exe 'sign place' key 'line='.ic.' name=ctrlpmark buffer='.s:bufnr
|
exe 'sign place' key 'line='.ic.' name=ctrlpmark buffer='.s:bufnr
|
||||||
en
|
en
|
||||||
@ -1195,13 +1198,13 @@ fu! s:vacantdict(dict)
|
|||||||
retu filter(range(1, max(keys(a:dict))), '!has_key(a:dict, v:val)')
|
retu filter(range(1, max(keys(a:dict))), '!has_key(a:dict, v:val)')
|
||||||
endf
|
endf
|
||||||
" Buffers {{{2
|
" Buffers {{{2
|
||||||
fu! s:buftab(bufnum, md)
|
fu! s:buftab(bufnr, md)
|
||||||
for tabnr in range(1, tabpagenr('$'))
|
for tabnr in range(1, tabpagenr('$'))
|
||||||
if tabpagenr() == tabnr && a:md == 't' | con | en
|
if tabpagenr() == tabnr && a:md == 't' | con | en
|
||||||
let buflist = tabpagebuflist(tabnr)
|
let buflist = tabpagebuflist(tabnr)
|
||||||
if index(buflist, a:bufnum) >= 0
|
if index(buflist, a:bufnr) >= 0
|
||||||
for winnr in range(1, tabpagewinnr(tabnr, '$'))
|
for winnr in range(1, tabpagewinnr(tabnr, '$'))
|
||||||
if buflist[winnr - 1] == a:bufnum
|
if buflist[winnr - 1] == a:bufnr
|
||||||
retu [tabnr, winnr]
|
retu [tabnr, winnr]
|
||||||
en
|
en
|
||||||
endfo
|
endfo
|
||||||
@ -1222,11 +1225,10 @@ fu! s:normbuf()
|
|||||||
retu winnrs
|
retu winnrs
|
||||||
endf
|
endf
|
||||||
|
|
||||||
fu! ctrlp#normcmd(cmd)
|
fu! ctrlp#normcmd(cmd, ...)
|
||||||
if s:nosplit()
|
if s:nosplit()
|
||||||
retu a:cmd
|
retu a:cmd
|
||||||
en
|
en
|
||||||
" Find a normal buffer
|
|
||||||
let norwins = s:normbuf()
|
let norwins = s:normbuf()
|
||||||
for each in norwins
|
for each in norwins
|
||||||
let bufnr = winbufnr(each)
|
let bufnr = winbufnr(each)
|
||||||
@ -1242,7 +1244,7 @@ fu! ctrlp#normcmd(cmd)
|
|||||||
en
|
en
|
||||||
retu a:cmd
|
retu a:cmd
|
||||||
en
|
en
|
||||||
retu 'bo vne'
|
retu a:0 ? a:1 : 'bo vne'
|
||||||
endf
|
endf
|
||||||
|
|
||||||
fu! s:nosplit()
|
fu! s:nosplit()
|
||||||
@ -1350,7 +1352,7 @@ fu! ctrlp#msg(msg)
|
|||||||
endf
|
endf
|
||||||
|
|
||||||
fu! s:openfile(cmd, filpath, ...)
|
fu! s:openfile(cmd, filpath, ...)
|
||||||
let cmd = a:cmd == 'e' && &modified ? 'hid e' : a:cmd
|
let cmd = a:cmd =~ '^e$\|^b$' && &modified ? 'hid '.a:cmd : a:cmd
|
||||||
let tail = a:0 ? a:1 : s:tail()
|
let tail = a:0 ? a:1 : s:tail()
|
||||||
try
|
try
|
||||||
exe cmd.tail.' '.ctrlp#fnesc(a:filpath)
|
exe cmd.tail.' '.ctrlp#fnesc(a:filpath)
|
||||||
@ -1378,10 +1380,6 @@ fu! ctrlp#j2l(nr)
|
|||||||
sil! norm! zvzz
|
sil! norm! zvzz
|
||||||
endf
|
endf
|
||||||
|
|
||||||
fu! s:nocwd()
|
|
||||||
retu !s:itemtype || ( s:itemtype == 2 && s:relate )
|
|
||||||
endf
|
|
||||||
|
|
||||||
fu! s:regexfilter(str)
|
fu! s:regexfilter(str)
|
||||||
let str = a:str
|
let str = a:str
|
||||||
for key in keys(s:fpats) | if match(str, key) >= 0
|
for key in keys(s:fpats) | if match(str, key) >= 0
|
||||||
|
@ -181,7 +181,10 @@ fu! s:process(fname, ftype)
|
|||||||
let data = s:exectagsonfile(a:fname, a:ftype)
|
let data = s:exectagsonfile(a:fname, a:ftype)
|
||||||
let [raw, lines] = [split(data, '\n\+'), []]
|
let [raw, lines] = [split(data, '\n\+'), []]
|
||||||
for line in raw | if len(split(line, ';"')) == 2
|
for line in raw | if len(split(line, ';"')) == 2
|
||||||
cal add(lines, s:parseline(line))
|
let parsed_line = s:parseline(line)
|
||||||
|
if parsed_line != ''
|
||||||
|
cal add(lines, parsed_line)
|
||||||
|
en
|
||||||
en | endfo
|
en | endfo
|
||||||
let cache = { a:fname : { 'time': ftime, 'lines': lines } }
|
let cache = { a:fname : { 'time': ftime, 'lines': lines } }
|
||||||
cal extend(g:ctrlp_buftags, cache)
|
cal extend(g:ctrlp_buftags, cache)
|
||||||
|
@ -26,7 +26,8 @@ let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars)
|
|||||||
fu! ctrlp#rtscript#init()
|
fu! ctrlp#rtscript#init()
|
||||||
if g:ctrlp_newrts || !exists('g:ctrlp_rtscache')
|
if g:ctrlp_newrts || !exists('g:ctrlp_rtscache')
|
||||||
sil! cal ctrlp#progress('Indexing...')
|
sil! cal ctrlp#progress('Indexing...')
|
||||||
let entries = split(globpath(&rtp, '**/*.\(vim\|txt\)'), "\n")
|
let entries = split(globpath(&rtp, '**/*.*'), "\n")
|
||||||
|
cal filter(entries,'index(entries, v:val, v:key + 1) < 0')
|
||||||
let [g:ctrlp_rtscache, g:ctrlp_newrts] = [ctrlp#dirnfile(entries)[1], 0]
|
let [g:ctrlp_rtscache, g:ctrlp_newrts] = [ctrlp#dirnfile(entries)[1], 0]
|
||||||
en
|
en
|
||||||
retu g:ctrlp_rtscache
|
retu g:ctrlp_rtscache
|
||||||
|
@ -15,16 +15,12 @@ fu! s:lash(...)
|
|||||||
endf
|
endf
|
||||||
|
|
||||||
fu! ctrlp#utils#opts()
|
fu! ctrlp#utils#opts()
|
||||||
let cache_home = exists('$XDG_CACHE_HOME') ? $XDG_CACHE_HOME : $HOME.'/.cache'
|
let usrhome = $HOME.s:lash($HOME)
|
||||||
let s:cache_dir = cache_home.'/ctrlp'
|
let cahome = exists('$XDG_CACHE_HOME') ? $XDG_CACHE_HOME : usrhome.'.cache'
|
||||||
" Support old default, for compatibility
|
let s:cache_dir = isdirectory(usrhome.'.ctrlp_cache')
|
||||||
if !isdirectory(s:cache_dir) && isdirectory($HOME.s:lash($HOME).'.ctrlp_cache')
|
\ ? usrhome.'.ctrlp_cache' : cahome.s:lash(cahome).'ctrlp'
|
||||||
let s:cache_dir = $HOME.s:lash($HOME).'.ctrlp_cache'
|
|
||||||
en
|
|
||||||
" User option
|
|
||||||
if exists('g:ctrlp_cache_dir')
|
if exists('g:ctrlp_cache_dir')
|
||||||
let s:cache_dir = expand(g:ctrlp_cache_dir, 1)
|
let s:cache_dir = expand(g:ctrlp_cache_dir, 1)
|
||||||
" Support old suffix
|
|
||||||
if isdirectory(s:cache_dir.s:lash(s:cache_dir).'.ctrlp_cache')
|
if isdirectory(s:cache_dir.s:lash(s:cache_dir).'.ctrlp_cache')
|
||||||
let s:cache_dir = s:cache_dir.s:lash(s:cache_dir).'.ctrlp_cache'
|
let s:cache_dir = s:cache_dir.s:lash(s:cache_dir).'.ctrlp_cache'
|
||||||
en
|
en
|
||||||
@ -60,10 +56,16 @@ fu! ctrlp#utils#mkdir(dir)
|
|||||||
en
|
en
|
||||||
endf
|
endf
|
||||||
|
|
||||||
|
fu! ctrlp#utils#createpath(arr)
|
||||||
|
for each in a:arr
|
||||||
|
let curr = exists('curr') ? curr.s:lash(curr).each : each
|
||||||
|
cal ctrlp#utils#mkdir(curr)
|
||||||
|
endfo
|
||||||
|
retu curr
|
||||||
|
endf
|
||||||
|
|
||||||
fu! ctrlp#utils#writecache(lines, ...)
|
fu! ctrlp#utils#writecache(lines, ...)
|
||||||
let cache_dir = exists('a:1') ? a:1 : s:cache_dir
|
if isdirectory(ctrlp#utils#createpath(split(a:0 ? a:1 : s:cache_dir, '[\/]')))
|
||||||
cal ctrlp#utils#mkdir(cache_dir)
|
|
||||||
if isdirectory(cache_dir)
|
|
||||||
sil! cal writefile(a:lines, exists('a:2') ? a:2 : ctrlp#utils#cachefile())
|
sil! cal writefile(a:lines, exists('a:2') ? a:2 : ctrlp#utils#cachefile())
|
||||||
if !exists('a:1')
|
if !exists('a:1')
|
||||||
let g:ctrlp_newcache = 0
|
let g:ctrlp_newcache = 0
|
||||||
|
@ -640,9 +640,9 @@ Available extensions:~
|
|||||||
|
|
||||||
*:CtrlPRTS*
|
*:CtrlPRTS*
|
||||||
* Runtime script mode:~
|
* Runtime script mode:~
|
||||||
- Name: 'rts'
|
- Name: 'rtscript'
|
||||||
- Command: ':CtrlPRTS'
|
- Command: ':CtrlPRTS'
|
||||||
- Search for vimscripts in runtimepath.
|
- Search for files (vimscripts, docs...) in runtimepath.
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Buffer Tag mode options:~
|
Buffer Tag mode options:~
|
||||||
|
@ -26,7 +26,9 @@ com! CtrlPCurWD cal ctrlp#init(0, 0)
|
|||||||
com! CtrlPCurFile cal ctrlp#init(0, 1)
|
com! CtrlPCurFile cal ctrlp#init(0, 1)
|
||||||
com! CtrlPRoot cal ctrlp#init(0, 2)
|
com! CtrlPRoot cal ctrlp#init(0, 2)
|
||||||
|
|
||||||
exe 'nn <silent>' g:ctrlp_map ':<c-u>'.g:ctrlp_cmd.'<cr>'
|
if g:ctrlp_map != ''
|
||||||
|
exe 'nn <silent>' g:ctrlp_map ':<c-u>'.g:ctrlp_cmd.'<cr>'
|
||||||
|
en
|
||||||
|
|
||||||
cal ctrlp#mrufiles#init()
|
cal ctrlp#mrufiles#init()
|
||||||
|
|
||||||
|
@ -51,8 +51,7 @@ e.g. `abc:45` will open the file matched the pattern and jump to line 45.
|
|||||||
root.dir
|
root.dir
|
||||||
|
|
||||||
* If you want to exclude directories or files from the search, you can use the Vim’s option `wildignore`
|
* If you want to exclude directories or files from the search, you can use the Vim’s option `wildignore`
|
||||||
and/or the option `g:ctrlp_custom_ignore`.
|
and/or the option `g:ctrlp_custom_ignore`. Examples:
|
||||||
Examples:
|
|
||||||
|
|
||||||
```vim
|
```vim
|
||||||
set wildignore+=*/.git/*,*/.hg/*,*/.svn/* " for Linux/MacOSX
|
set wildignore+=*/.git/*,*/.hg/*,*/.svn/* " for Linux/MacOSX
|
||||||
|
Loading…
x
Reference in New Issue
Block a user