Some improvements
* More graceful degradation for 700, 701 * Simplify insertcache() * Correct SetWorkingPath()'s behavior * Reserve Open-Multiple-Files for built-ins
This commit is contained in:
parent
9dcef3db12
commit
ae6f1592b4
@ -2,7 +2,7 @@
|
|||||||
" File: autoload/ctrlp.vim
|
" File: autoload/ctrlp.vim
|
||||||
" Description: Full path fuzzy file, buffer and MRU file finder for Vim
|
" Description: Full path fuzzy file, buffer and MRU file finder for Vim
|
||||||
" Author: Kien Nguyen <github.com/kien>
|
" Author: Kien Nguyen <github.com/kien>
|
||||||
" Version: 1.5.7
|
" Version: 1.5.8
|
||||||
" =============================================================================
|
" =============================================================================
|
||||||
|
|
||||||
" Static variables {{{
|
" Static variables {{{
|
||||||
@ -26,7 +26,7 @@ fu! s:opts()
|
|||||||
\ 'g:ctrlp_root_markers': ['s:rmarkers', []],
|
\ 'g:ctrlp_root_markers': ['s:rmarkers', []],
|
||||||
\ 'g:ctrlp_split_window': ['s:splitwin', 0],
|
\ 'g:ctrlp_split_window': ['s:splitwin', 0],
|
||||||
\ 'g:ctrlp_use_caching': ['s:caching', 1],
|
\ 'g:ctrlp_use_caching': ['s:caching', 1],
|
||||||
\ 'g:ctrlp_working_path_mode': ['s:pathmode', 1],
|
\ 'g:ctrlp_working_path_mode': ['s:pathmode', 2],
|
||||||
\ }
|
\ }
|
||||||
for key in keys(opts)
|
for key in keys(opts)
|
||||||
let def = string(exists(key) ? eval(key) : opts[key][1])
|
let def = string(exists(key) ? eval(key) : opts[key][1])
|
||||||
@ -70,7 +70,7 @@ fu! s:Open()
|
|||||||
let s:hstry = empty(hst) || !s:maxhst ? [''] : hst
|
let s:hstry = empty(hst) || !s:maxhst ? [''] : hst
|
||||||
en
|
en
|
||||||
for key in keys(s:glbs)
|
for key in keys(s:glbs)
|
||||||
exe 'let s:glb_'.key.' = &'.key.' | let &'.key.' = '.string(s:glbs[key])
|
sil! exe 'let s:glb_'.key.' = &'.key.' | let &'.key.' = '.string(s:glbs[key])
|
||||||
endfo
|
endfo
|
||||||
if s:opmul && has('signs')
|
if s:opmul && has('signs')
|
||||||
sign define ctrlpmark text=+> texthl=Search
|
sign define ctrlpmark text=+> texthl=Search
|
||||||
@ -82,7 +82,7 @@ fu! s:Close()
|
|||||||
try | bun! | cat | clo! | endt
|
try | bun! | cat | clo! | endt
|
||||||
cal s:unmarksigns()
|
cal s:unmarksigns()
|
||||||
for key in keys(s:glbs)
|
for key in keys(s:glbs)
|
||||||
exe 'let &'.key.' = s:glb_'.key
|
sil! exe 'let &'.key.' = s:glb_'.key
|
||||||
endfo
|
endfo
|
||||||
if exists('s:glb_acd') | let &acd = s:glb_acd | en
|
if exists('s:glb_acd') | let &acd = s:glb_acd | en
|
||||||
let [g:ctrlp_lines, g:ctrlp_allfiles] = [[], []]
|
let [g:ctrlp_lines, g:ctrlp_allfiles] = [[], []]
|
||||||
@ -103,9 +103,9 @@ endf
|
|||||||
fu! ctrlp#clearallcaches()
|
fu! ctrlp#clearallcaches()
|
||||||
let cache_dir = ctrlp#utils#cachedir()
|
let cache_dir = ctrlp#utils#cachedir()
|
||||||
if isdirectory(cache_dir) && match(cache_dir, '.ctrlp_cache') >= 0
|
if isdirectory(cache_dir) && match(cache_dir, '.ctrlp_cache') >= 0
|
||||||
let cache_files = split(globpath(cache_dir, '*.txt', 1), '\n')
|
let cache_files = split(globpath(cache_dir, '*.txt'), '\n')
|
||||||
cal filter(cache_files, '!isdirectory(v:val)')
|
cal filter(cache_files, '!isdirectory(v:val)')
|
||||||
for each in cache_files | sil! cal delete(each) | endfo
|
sil! cal map(cache_files, 'delete(v:val)')
|
||||||
en
|
en
|
||||||
cal ctrlp#clearcache()
|
cal ctrlp#clearcache()
|
||||||
endf
|
endf
|
||||||
@ -118,7 +118,7 @@ fu! ctrlp#reset()
|
|||||||
unl! s:cline
|
unl! s:cline
|
||||||
endf
|
endf
|
||||||
"}}}
|
"}}}
|
||||||
" * ListAllFiles {{{
|
" * Files() {{{
|
||||||
fu! s:GlobPath(dirs, allfiles, depth)
|
fu! s:GlobPath(dirs, allfiles, depth)
|
||||||
let entries = split(globpath(a:dirs, s:glob), '\n')
|
let entries = split(globpath(a:dirs, s:glob), '\n')
|
||||||
let entries = filter(entries, 'getftype(v:val) != "link"')
|
let entries = filter(entries, 'getftype(v:val) != "link"')
|
||||||
@ -149,7 +149,7 @@ fu! s:UserCommand(path, lscmd)
|
|||||||
en
|
en
|
||||||
endf
|
endf
|
||||||
|
|
||||||
fu! s:ListAllFiles(path)
|
fu! s:Files(path)
|
||||||
let cache_file = ctrlp#utils#cachefile()
|
let cache_file = ctrlp#utils#cachefile()
|
||||||
if g:ctrlp_newcache || !filereadable(cache_file) || !s:caching
|
if g:ctrlp_newcache || !filereadable(cache_file) || !s:caching
|
||||||
let lscmd = s:lscommand()
|
let lscmd = s:lscommand()
|
||||||
@ -172,16 +172,11 @@ fu! s:ListAllFiles(path)
|
|||||||
if len(g:ctrlp_allfiles) <= s:compare_lim
|
if len(g:ctrlp_allfiles) <= s:compare_lim
|
||||||
cal sort(g:ctrlp_allfiles, 's:complen')
|
cal sort(g:ctrlp_allfiles, 's:complen')
|
||||||
en
|
en
|
||||||
" Write cache
|
cal s:writecache(read_cache, cache_file)
|
||||||
if !read_cache && ( ( g:ctrlp_newcache || !filereadable(cache_file) )
|
|
||||||
\ && s:caching || len(g:ctrlp_allfiles) > s:nocache_lim )
|
|
||||||
if len(g:ctrlp_allfiles) > s:nocache_lim | let s:caching = 1 | en
|
|
||||||
cal ctrlp#utils#writecache(g:ctrlp_allfiles)
|
|
||||||
en
|
|
||||||
retu g:ctrlp_allfiles
|
retu g:ctrlp_allfiles
|
||||||
endf
|
endf
|
||||||
"}}}
|
"}}}
|
||||||
fu! s:ListAllBuffers() "{{{
|
fu! s:Buffers() "{{{
|
||||||
let allbufs = []
|
let allbufs = []
|
||||||
for each in range(1, bufnr('$'))
|
for each in range(1, bufnr('$'))
|
||||||
if getbufvar(each, '&bl')
|
if getbufvar(each, '&bl')
|
||||||
@ -193,7 +188,7 @@ fu! s:ListAllBuffers() "{{{
|
|||||||
endfo
|
endfo
|
||||||
retu allbufs
|
retu allbufs
|
||||||
endf "}}}
|
endf "}}}
|
||||||
" * GetMatchedItems {{{
|
" * MatchedItems() {{{
|
||||||
fu! s:MatchIt(items, pat, limit)
|
fu! s:MatchIt(items, pat, limit)
|
||||||
let [items, pat, limit, newitems] = [a:items, a:pat, a:limit, []]
|
let [items, pat, limit, newitems] = [a:items, a:pat, a:limit, []]
|
||||||
let mfunc = s:byfname ? 's:matchsubstr' : 'match'
|
let mfunc = s:byfname ? 's:matchsubstr' : 'match'
|
||||||
@ -204,7 +199,7 @@ fu! s:MatchIt(items, pat, limit)
|
|||||||
retu newitems
|
retu newitems
|
||||||
endf
|
endf
|
||||||
|
|
||||||
fu! s:GetMatchedItems(items, pats, limit)
|
fu! s:MatchedItems(items, pats, limit)
|
||||||
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 | let pats = [pats[-1]] | en
|
if len(items) >= s:mltipats_lim | let pats = [pats[-1]] | en
|
||||||
@ -265,8 +260,8 @@ fu! s:SplitPattern(str,...) "{{{
|
|||||||
en
|
en
|
||||||
retu newpats
|
retu newpats
|
||||||
endf "}}}
|
endf "}}}
|
||||||
" * BuildPrompt {{{
|
" * BuildPrompt() {{{
|
||||||
fu! s:Renderer(lines, pat)
|
fu! s:Render(lines, pat)
|
||||||
let lines = a:lines
|
let lines = a:lines
|
||||||
" Setup the match window
|
" Setup the match window
|
||||||
sil! exe '%d _ | res' min([len(lines), s:mxheight])
|
sil! exe '%d _ | res' min([len(lines), s:mxheight])
|
||||||
@ -290,7 +285,7 @@ fu! s:Renderer(lines, pat)
|
|||||||
exe 'keepj norm!' s:mwreverse ? 'G' : 'gg'
|
exe 'keepj norm!' s:mwreverse ? 'G' : 'gg'
|
||||||
keepj norm! 1|
|
keepj norm! 1|
|
||||||
cal s:unmarksigns()
|
cal s:unmarksigns()
|
||||||
cal s:remarksigns(s:matched)
|
cal s:remarksigns()
|
||||||
en
|
en
|
||||||
if exists('s:cline') | cal cursor(s:cline, 1) | en
|
if exists('s:cline') | cal cursor(s:cline, 1) | en
|
||||||
" Highlighting
|
" Highlighting
|
||||||
@ -301,7 +296,7 @@ fu! s:Renderer(lines, pat)
|
|||||||
en
|
en
|
||||||
endf
|
endf
|
||||||
|
|
||||||
fu! s:UpdateMatches(pat,...)
|
fu! s:Update(pat,...)
|
||||||
let pat = a:pat
|
let pat = a:pat
|
||||||
" Get the previous string if existed
|
" Get the previous string if existed
|
||||||
let oldstr = exists('s:savestr') ? s:savestr : ''
|
let oldstr = exists('s:savestr') ? s:savestr : ''
|
||||||
@ -312,9 +307,9 @@ fu! s:UpdateMatches(pat,...)
|
|||||||
if notail == oldstr && !empty(notail) && !exists('a:1') && !exists('s:force')
|
if notail == oldstr && !empty(notail) && !exists('a:1') && !exists('s:force')
|
||||||
retu
|
retu
|
||||||
en
|
en
|
||||||
let lines = s:GetMatchedItems(g:ctrlp_lines, pats, s:mxheight)
|
let lines = s:MatchedItems(g:ctrlp_lines, pats, s:mxheight)
|
||||||
let pat = pats[-1]
|
let pat = pats[-1]
|
||||||
cal s:Renderer(lines, pat)
|
cal s:Render(lines, pat)
|
||||||
endf
|
endf
|
||||||
|
|
||||||
fu! s:BuildPrompt(upd,...)
|
fu! s:BuildPrompt(upd,...)
|
||||||
@ -323,7 +318,7 @@ fu! s:BuildPrompt(upd,...)
|
|||||||
cal map(prt, 'escape(v:val, estr)')
|
cal map(prt, 'escape(v:val, estr)')
|
||||||
let str = join(prt, '')
|
let str = join(prt, '')
|
||||||
if a:upd && ( s:matches || s:regexp || match(str, '[*|]') >= 0 )
|
if a:upd && ( s:matches || s:regexp || match(str, '[*|]') >= 0 )
|
||||||
sil! cal call('s:UpdateMatches', exists('a:2') ? [str, a:2] : [str])
|
sil! cal call('s:Update', exists('a:2') ? [str, a:2] : [str])
|
||||||
en
|
en
|
||||||
sil! cal s:statusline()
|
sil! cal s:statusline()
|
||||||
" Toggling
|
" Toggling
|
||||||
@ -482,7 +477,7 @@ fu! s:PrtHistory(...)
|
|||||||
endf
|
endf
|
||||||
"}}}
|
"}}}
|
||||||
"}}}
|
"}}}
|
||||||
" * MapKeys {{{
|
" * MapKeys() {{{
|
||||||
fu! s:MapKeys(...)
|
fu! s:MapKeys(...)
|
||||||
" Normal keys
|
" Normal keys
|
||||||
let pfunc = exists('a:1') && !a:1 ? 'PrtSelectJump' : 'PrtAdd'
|
let pfunc = exists('a:1') && !a:1 ? 'PrtSelectJump' : 'PrtAdd'
|
||||||
@ -599,33 +594,31 @@ fu! s:PrtSwitcher()
|
|||||||
endf
|
endf
|
||||||
"}}}
|
"}}}
|
||||||
fu! ctrlp#SetWorkingPath(...) "{{{
|
fu! ctrlp#SetWorkingPath(...) "{{{
|
||||||
let [l:pathmode, s:cwd] = [2, getcwd()]
|
let [pathmode, s:cwd] = [s:pathmode, getcwd()]
|
||||||
if exists('a:1') && len(a:1) == 1 && !type(a:1)
|
if exists('a:1') && len(a:1) == 1 && !type(a:1)
|
||||||
let l:pathmode = a:1
|
let pathmode = a:1
|
||||||
elsei exists('a:1') && len(a:1) > 1 && type(a:1)
|
elsei exists('a:1') && len(a:1) > 1 && type(a:1)
|
||||||
sil! exe 'chd!' a:1
|
sil! exe 'chd!' a:1
|
||||||
retu
|
retu
|
||||||
en
|
en
|
||||||
if match(expand('%:p', 1), '^\<.\+\>://.*') >= 0 || !s:pathmode || !l:pathmode
|
if match(expand('%:p', 1), '^\<.\+\>://.*') >= 0 || !pathmode
|
||||||
retu
|
retu
|
||||||
en
|
en
|
||||||
if exists('+acd') | let [s:glb_acd, &acd] = [&acd, 0] | en
|
if exists('+acd') | let [s:glb_acd, &acd] = [&acd, 0] | en
|
||||||
let path = expand('%:p:h', 1)
|
let path = expand('%:p:h', 1)
|
||||||
let path = exists('*fnameescape') ? fnameescape(path) : escape(path, '%#')
|
let path = exists('*fnameescape') ? fnameescape(path) : escape(path, '%#')
|
||||||
if s:pathmode == 1 || l:pathmode == 1
|
sil! exe 'chd!' path
|
||||||
sil! exe 'chd!' path
|
if pathmode == 1 | retu | en
|
||||||
retu
|
|
||||||
en
|
|
||||||
let markers = ['root.dir','.git/','.hg/','.vimprojects','_darcs/','.bzr/']
|
let markers = ['root.dir','.git/','.hg/','.vimprojects','_darcs/','.bzr/']
|
||||||
if type(s:rmarkers) == 3 && !empty(s:rmarkers)
|
if type(s:rmarkers) == 3 && !empty(s:rmarkers)
|
||||||
cal extend(markers, s:rmarkers, 0)
|
cal extend(markers, s:rmarkers, 0)
|
||||||
en
|
en
|
||||||
for marker in markers
|
for marker in markers
|
||||||
let found = s:findroot(path, marker, 0, 0)
|
let found = s:findroot(getcwd(), marker, 0, 0)
|
||||||
if getcwd() != expand('%:p:h', 1) || found | brea | en
|
if getcwd() != expand('%:p:h', 1) || found | brea | en
|
||||||
endfo
|
endfo
|
||||||
endf "}}}
|
endf "}}}
|
||||||
" * AcceptSelection {{{
|
" * AcceptSelection() {{{
|
||||||
fu! ctrlp#acceptfile(mode, matchstr)
|
fu! ctrlp#acceptfile(mode, matchstr)
|
||||||
let [md, matchstr] = [a:mode, a:matchstr]
|
let [md, matchstr] = [a:mode, a:matchstr]
|
||||||
" Get the full path
|
" Get the full path
|
||||||
@ -728,13 +721,12 @@ fu! s:CreateNewFile() "{{{
|
|||||||
cal s:insertcache(str)
|
cal s:insertcache(str)
|
||||||
cal s:PrtExit()
|
cal s:PrtExit()
|
||||||
if s:newfop == 1 | tabnew | en
|
if s:newfop == 1 | tabnew | en
|
||||||
let opcmd = cmd.' '.escape(getcwd().s:lash.optyp, '%#')
|
cal s:openfile(cmd.' '.escape(getcwd().s:lash.optyp, '%#'))
|
||||||
cal s:openfile(opcmd)
|
|
||||||
en
|
en
|
||||||
endf "}}}
|
endf "}}}
|
||||||
" * OpenMulti {{{
|
" * OpenMulti() {{{
|
||||||
fu! s:MarkToOpen()
|
fu! s:MarkToOpen()
|
||||||
if s:bufnr <= 0 || !s:opmul | retu | en
|
if s:bufnr <= 0 || !s:opmul || s:itemtype > g:ctrlp_builtins | retu | 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:itemtype ? matchstr : getcwd().s:lash.matchstr
|
let filpath = s:itemtype ? matchstr : getcwd().s:lash.matchstr
|
||||||
@ -924,7 +916,7 @@ endf
|
|||||||
|
|
||||||
fu! s:listdirs(path,parent)
|
fu! s:listdirs(path,parent)
|
||||||
let str = ''
|
let str = ''
|
||||||
for entry in filter(split(globpath(a:path, '*', 1), '\n'), 'isdirectory(v:val)')
|
for entry in filter(split(globpath(a:path, '*'), '\n'), 'isdirectory(v:val)')
|
||||||
let str .= a:parent . split(entry, '[\/]')[-1] . "\n"
|
let str .= a:parent . split(entry, '[\/]')[-1] . "\n"
|
||||||
endfo
|
endfo
|
||||||
retu str
|
retu str
|
||||||
@ -938,9 +930,14 @@ fu! ctrlp#compl(A,L,P)
|
|||||||
endf
|
endf
|
||||||
|
|
||||||
fu! s:findroot(curr, mark, depth, type)
|
fu! s:findroot(curr, mark, depth, type)
|
||||||
let [depth, notfound] = [a:depth + 1, empty(globpath(a:curr, a:mark, 1))]
|
let [depth, notfound] = [a:depth + 1, empty(globpath(a:curr, a:mark))]
|
||||||
if !notfound || depth > s:maxdepth
|
if !notfound || depth > s:maxdepth
|
||||||
if notfound | retu 0 | en
|
if notfound
|
||||||
|
if exists('s:cwd')
|
||||||
|
sil! exe 'chd!' s:cwd
|
||||||
|
en
|
||||||
|
retu 0
|
||||||
|
en
|
||||||
if a:type
|
if a:type
|
||||||
let s:vcsroot = depth <= s:maxdepth ? a:curr : ''
|
let s:vcsroot = depth <= s:maxdepth ? a:curr : ''
|
||||||
el
|
el
|
||||||
@ -1002,9 +999,9 @@ fu! s:unmarksigns()
|
|||||||
endfo
|
endfo
|
||||||
endf
|
endf
|
||||||
|
|
||||||
fu! s:remarksigns(nls)
|
fu! s:remarksigns()
|
||||||
if !s:dosigns() | retu | en
|
if !s:dosigns() | retu | en
|
||||||
let nls = a:nls
|
let nls = s:matched
|
||||||
for ic in range(1, len(nls))
|
for ic in range(1, len(nls))
|
||||||
let filpath = s:itemtype ? nls[ic - 1] : getcwd().s:lash.nls[ic - 1]
|
let filpath = s:itemtype ? nls[ic - 1] : getcwd().s:lash.nls[ic - 1]
|
||||||
let key = s:dictindex(s:marked, filpath)
|
let key = s:dictindex(s:marked, filpath)
|
||||||
@ -1082,6 +1079,14 @@ fu! s:checkbuf()
|
|||||||
endf
|
endf
|
||||||
"}}}
|
"}}}
|
||||||
" Misc {{{
|
" Misc {{{
|
||||||
|
fu! s:writecache(read_cache, cache_file)
|
||||||
|
if !a:read_cache && ( ( g:ctrlp_newcache || !filereadable(a:cache_file) )
|
||||||
|
\ && s:caching || len(g:ctrlp_allfiles) > s:nocache_lim )
|
||||||
|
if len(g:ctrlp_allfiles) > s:nocache_lim | let s:caching = 1 | en
|
||||||
|
cal ctrlp#utils#writecache(g:ctrlp_allfiles)
|
||||||
|
en
|
||||||
|
endf
|
||||||
|
|
||||||
fu! s:regexfilter(str)
|
fu! s:regexfilter(str)
|
||||||
let str = a:str
|
let str = a:str
|
||||||
let pats = {
|
let pats = {
|
||||||
@ -1104,7 +1109,9 @@ fu! s:openfile(cmd)
|
|||||||
try
|
try
|
||||||
exe a:cmd
|
exe a:cmd
|
||||||
cat
|
cat
|
||||||
echoe 'CtrlP: Operation can''t be completed. Make sure filename is valid.'
|
echoh Identifier
|
||||||
|
echon "CtrlP: Operation can't be completed. Make sure filename is valid."
|
||||||
|
echoh None
|
||||||
endt
|
endt
|
||||||
endf
|
endf
|
||||||
|
|
||||||
@ -1121,29 +1128,21 @@ fu! s:maxfiles(len)
|
|||||||
endf
|
endf
|
||||||
|
|
||||||
fu! s:insertcache(str)
|
fu! s:insertcache(str)
|
||||||
let cache_file = ctrlp#utils#cachefile()
|
if match(a:str, '|\|?\|:\|"\|\*\|<\|>') >= 0 | retu | en
|
||||||
if filereadable(cache_file)
|
let [data, g:ctrlp_newcache, str] = [g:ctrlp_allfiles, 1, a:str]
|
||||||
let data = readfile(cache_file)
|
if strlen(str) <= strlen(data[0])
|
||||||
if index(data, a:str) >= 0 | retu | en
|
let pos = 0
|
||||||
if strlen(a:str) <= strlen(data[0])
|
elsei strlen(str) >= strlen(data[-1])
|
||||||
let pos = 0
|
let pos = len(data) - 1
|
||||||
elsei strlen(a:str) >= strlen(data[-1])
|
el
|
||||||
let pos = len(data) - 1
|
let pos = 0
|
||||||
el
|
for each in data
|
||||||
" Boost the value
|
if strlen(each) > strlen(str) | brea | en
|
||||||
let strlen = abs((strlen(a:str) - strlen(data[0])) * 100000)
|
let pos += 1
|
||||||
let fullen = abs(strlen(data[-1]) - strlen(data[0]))
|
endfo
|
||||||
let posi = string(len(data) * strlen / fullen)
|
|
||||||
" Find and move the floating point back
|
|
||||||
let floatpos = stridx(posi, '.')
|
|
||||||
let posi = substitute(posi, '\.', '', 'g')
|
|
||||||
let posi = join(insert(split(posi, '\zs'), '.', floatpos - 5), '')
|
|
||||||
" Get the approximate integer
|
|
||||||
let pos = float2nr(round(str2float(posi)))
|
|
||||||
en
|
|
||||||
cal insert(data, a:str, pos)
|
|
||||||
cal ctrlp#utils#writecache(data)
|
|
||||||
en
|
en
|
||||||
|
cal insert(data, str, pos)
|
||||||
|
cal s:writecache(0, ctrlp#utils#cachefile())
|
||||||
endf
|
endf
|
||||||
|
|
||||||
fu! s:lscommand()
|
fu! s:lscommand()
|
||||||
@ -1170,8 +1169,8 @@ endf
|
|||||||
fu! s:SetLines(type)
|
fu! s:SetLines(type)
|
||||||
let s:itemtype = a:type
|
let s:itemtype = a:type
|
||||||
let types = [
|
let types = [
|
||||||
\ 's:ListAllFiles(getcwd())',
|
\ 's:Files(getcwd())',
|
||||||
\ 's:ListAllBuffers()',
|
\ 's:Buffers()',
|
||||||
\ 'ctrlp#mrufiles#list(-1)',
|
\ 'ctrlp#mrufiles#list(-1)',
|
||||||
\ ]
|
\ ]
|
||||||
if !s:mru | cal remove(types, 2) | en
|
if !s:mru | cal remove(types, 2) | en
|
||||||
|
@ -50,7 +50,7 @@ fu! ctrlp#mrufiles#list(bufnr,...) "{{{
|
|||||||
endf "}}}
|
endf "}}}
|
||||||
fu! s:rmdeleted(mrufs, cadir, cafile) "{{{
|
fu! s:rmdeleted(mrufs, cadir, cafile) "{{{
|
||||||
for each in range(len(a:mrufs) - 1, 0, -1)
|
for each in range(len(a:mrufs) - 1, 0, -1)
|
||||||
if empty(glob(a:mrufs[each], 1))
|
if empty(glob(a:mrufs[each]))
|
||||||
cal remove(a:mrufs, each)
|
cal remove(a:mrufs, each)
|
||||||
en
|
en
|
||||||
endfo
|
endfo
|
||||||
|
110
doc/ctrlp.txt
110
doc/ctrlp.txt
@ -1,4 +1,4 @@
|
|||||||
*ctrlp.txt* Full path fuzzy file, buffer and MRU file finder. v1.5.7
|
*ctrlp.txt* Full path fuzzy file, buffer and MRU file finder. v1.5.8
|
||||||
*CtrlP* *ControlP* *'ctrlp'* *'ctrl-p'*
|
*CtrlP* *ControlP* *'ctrlp'* *'ctrl-p'*
|
||||||
===============================================================================
|
===============================================================================
|
||||||
# #
|
# #
|
||||||
@ -19,18 +19,13 @@ CONTENTS *ctrlp-contents*
|
|||||||
4. Mappings.....................................|ctrlp-mappings|
|
4. Mappings.....................................|ctrlp-mappings|
|
||||||
5. Input Formats................................|ctrlp-input-formats|
|
5. Input Formats................................|ctrlp-input-formats|
|
||||||
|
|
||||||
6. Credits......................................|ctrlp-credits|
|
|
||||||
7. Thanks.......................................|ctrlp-thanks|
|
|
||||||
8. Extending ctrlp..............................|ctrlp-extensions|
|
|
||||||
9. Changelog....................................|ctrlp-changelog|
|
|
||||||
|
|
||||||
===============================================================================
|
===============================================================================
|
||||||
1. Intro *ctrlp-intro*
|
1. Intro *ctrlp-intro*
|
||||||
|
|
||||||
Full path fuzzy file, buffer and MRU file finder with an intuitive interface.
|
Full path fuzzy file, buffer and MRU file finder with an intuitive interface.
|
||||||
Written in pure Vimscript for MacVim and Vim version 7.0+. Has full support for
|
Written in pure Vimscript for MacVim and Vim version 7.0+. Has full support for
|
||||||
Vim’s |regexp| as search pattern, built-in MRU monitoring, project’s root
|
Vim’s |regexp| as search pattern, built-in MRU monitoring, project’s root
|
||||||
finder, custom extensions, and more.
|
finder, and more.
|
||||||
|
|
||||||
===============================================================================
|
===============================================================================
|
||||||
2. Options *ctrlp-options*
|
2. Options *ctrlp-options*
|
||||||
@ -73,16 +68,6 @@ Set the maximum height of the match window: >
|
|||||||
let g:ctrlp_max_height = 10
|
let g:ctrlp_max_height = 10
|
||||||
<
|
<
|
||||||
|
|
||||||
*'g:ctrlp_split_window'*
|
|
||||||
Use this option to specify how the file is to be opened when pressing <cr>:
|
|
||||||
1 - in a new tab
|
|
||||||
2 - in a new horizontal split
|
|
||||||
3 - in a new vertical split
|
|
||||||
0 - in the current window
|
|
||||||
>
|
|
||||||
let g:ctrlp_split_window = 0
|
|
||||||
<
|
|
||||||
|
|
||||||
*'g:ctrlp_jump_to_buffer'*
|
*'g:ctrlp_jump_to_buffer'*
|
||||||
Set this to 0 to disable the jump-to-open-buffer feature; set to 2 to also jump
|
Set this to 0 to disable the jump-to-open-buffer feature; set to 2 to also jump
|
||||||
tab if the selected buffer’s opened in another tab: >
|
tab if the selected buffer’s opened in another tab: >
|
||||||
@ -91,7 +76,7 @@ tab if the selected buffer’s opened in another tab: >
|
|||||||
|
|
||||||
*'g:ctrlp_working_path_mode'*
|
*'g:ctrlp_working_path_mode'*
|
||||||
*SetWorkingPath()*
|
*SetWorkingPath()*
|
||||||
When starting up the prompt, automatically set the working directory (i.e. the
|
When starting up the prompt, temporarily set the working directory (i.e. the
|
||||||
|current-directory|) to:
|
|current-directory|) to:
|
||||||
1 - the parent directory of the current file.
|
1 - the parent directory of the current file.
|
||||||
2 - the nearest ancestor that contains one of these directories/files:
|
2 - the nearest ancestor that contains one of these directories/files:
|
||||||
@ -103,7 +88,7 @@ When starting up the prompt, automatically set the working directory (i.e. the
|
|||||||
.vimprojects
|
.vimprojects
|
||||||
0 - don’t manage working directory.
|
0 - don’t manage working directory.
|
||||||
>
|
>
|
||||||
let g:ctrlp_working_path_mode = 1
|
let g:ctrlp_working_path_mode = 2
|
||||||
<
|
<
|
||||||
You can use this functionality outside of |CtrlP| by adding the following line
|
You can use this functionality outside of |CtrlP| by adding the following line
|
||||||
to your |.vimrc|; the parameter is the same (1, 2 or 0): >
|
to your |.vimrc|; the parameter is the same (1, 2 or 0): >
|
||||||
@ -124,8 +109,7 @@ be enabled for directories that have more than 4000 files: >
|
|||||||
Note: you can quickly purge the cache by pressing <F5> while inside |CtrlP|.
|
Note: you can quickly purge the cache by pressing <F5> while inside |CtrlP|.
|
||||||
|
|
||||||
*'g:ctrlp_clear_cache_on_exit'*
|
*'g:ctrlp_clear_cache_on_exit'*
|
||||||
Set this to 0 to enable cross-sessions caching (not deleting the caches upon
|
Set this to 0 to enable cross-sessions caching: >
|
||||||
exiting Vim): >
|
|
||||||
let g:ctrlp_clear_cache_on_exit = 1
|
let g:ctrlp_clear_cache_on_exit = 1
|
||||||
<
|
<
|
||||||
|
|
||||||
@ -277,8 +261,8 @@ If non-zero this will enable opening multiple files with <c-z> and <c-o>: >
|
|||||||
let g:ctrlp_open_multi = 1
|
let g:ctrlp_open_multi = 1
|
||||||
<
|
<
|
||||||
If bigger than 1, it’ll be used as the maximum number of windows to create when
|
If bigger than 1, it’ll be used as the maximum number of windows to create when
|
||||||
opening the files (the rest will be hidden buffers). If is 1, it’ll open all
|
opening the files (the rest will be hidden buffers). If is 1, <c-o> will open
|
||||||
files, each in a vertical split.
|
all files, each in a vertical split.
|
||||||
|
|
||||||
===============================================================================
|
===============================================================================
|
||||||
3. Commands *ctrlp-commands*
|
3. Commands *ctrlp-commands*
|
||||||
@ -315,17 +299,20 @@ The following commands ignore the value of |g:ctrlp_working_path_mode|:
|
|||||||
|
|
||||||
*:CtrlPCurWD*
|
*:CtrlPCurWD*
|
||||||
:CtrlPCurWD
|
:CtrlPCurWD
|
||||||
Find files in the |current-directory| (without changing it).
|
This acts like |:CtrlP| with |path_mode| = 0
|
||||||
|
Find files in the |current-directory|.
|
||||||
|
|
||||||
*:CtrlPCurFile*
|
*:CtrlPCurFile*
|
||||||
:CtrlPCurFile
|
:CtrlPCurFile
|
||||||
Find files in the same directory as the current file, regardless of what the
|
This acts like |:CtrlP| with |path_mode| = 1
|
||||||
|current-directory| is.
|
Find files in the same directory as the active buffer, regardless of what
|
||||||
|
the |current-directory| is.
|
||||||
|
|
||||||
*:CtrlPRoot*
|
*:CtrlPRoot*
|
||||||
:CtrlPRoot
|
:CtrlPRoot
|
||||||
Same as |:CtrlPCurFile| but start from the project’s root.
|
This acts like |:CtrlP| with |path_mode| = 2
|
||||||
Check |g:ctrlp_working_path_mode| to see how |CtrlP| finds a root.
|
Find files in the project’s root directory.
|
||||||
|
Check |working_path_mode| to see how |CtrlP| finds a root.
|
||||||
|
|
||||||
===============================================================================
|
===============================================================================
|
||||||
4. Mappings *ctrlp-mappings*
|
4. Mappings *ctrlp-mappings*
|
||||||
@ -348,14 +335,12 @@ Once inside the prompt:
|
|||||||
|
|
||||||
<c-f>, 'forward'
|
<c-f>, 'forward'
|
||||||
<c-up>
|
<c-up>
|
||||||
Toggle between searching files and searching buffers. Or switch to the
|
Scroll to the 'next' search type in the sequence. Currently file, buffer
|
||||||
'next' search type in the sequence; currently files, buffers and most
|
and most recently used file (MRU) are available.
|
||||||
recently used files (MRU Files) are available.
|
|
||||||
|
|
||||||
<c-b>, 'backward'
|
<c-b>, 'backward'
|
||||||
<c-down>
|
<c-down>
|
||||||
Toggle between searching files and searching buffers. Or switch to the
|
Scroll to the 'previous' search type in the sequence.
|
||||||
'previous' search type in the sequence.
|
|
||||||
|
|
||||||
<tab>
|
<tab>
|
||||||
Toggle the focus between the match window and the prompt.
|
Toggle the focus between the match window and the prompt.
|
||||||
@ -449,7 +434,7 @@ b) Vim |regexp|. If the input string contains '*' or '|', it’ll be treated as
|
|||||||
a Vim’s |regexp| |pattern| without any modification.
|
a Vim’s |regexp| |pattern| 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| and |g:ctrlp_regexp_search|.
|
See also |ctrlp-fullregexp| (key map) and |g:ctrlp_regexp_search| (option).
|
||||||
|
|
||||||
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 ':' in the command,
|
command after opening the file. If you need to use ':' in the command,
|
||||||
@ -473,35 +458,11 @@ e) Type the name of a non-existent file and press <c-y> to create it.
|
|||||||
f) Submit ? to open this help file.
|
f) Submit ? to open this help file.
|
||||||
|
|
||||||
===============================================================================
|
===============================================================================
|
||||||
6. Credits *ctrlp-credits*
|
EXTENDING *ctrlp-extending*
|
||||||
|
|
||||||
Developed by Kien Nguyen (github.com/kien), primarily based on the Command-T
|
Extending |CtrlP| is made to be incredibly simple. Just create a .vim file
|
||||||
and the LustyExplorer plugins. No code was taken from these plugins, but I did
|
following a short guidelines, place the file in the right spot and add a line
|
||||||
clone the majority of their (awesome) interfaces and the way they work, added
|
to your .vimrc.
|
||||||
on top are a few additions of my own.
|
|
||||||
|
|
||||||
The basic part of this was originally written as a module for a would-be larger
|
|
||||||
plugin called AutoDoc.vim which I’ve stopped developing because of lost of
|
|
||||||
interest. I really liked the way Command-T and LustyExplorer deal with user’s
|
|
||||||
input, so I wrote a pure Vimscript version of their prompt window, intended to
|
|
||||||
use it for the aforementioned plugin.
|
|
||||||
|
|
||||||
Homepage: http://kien.github.com/ctrlp.vim
|
|
||||||
Git repository: https://github.com/kien/ctrlp.vim
|
|
||||||
Mercurial repository: https://bitbucket.org/kien/ctrlp.vim
|
|
||||||
|
|
||||||
===============================================================================
|
|
||||||
7. Thanks *ctrlp-thanks*
|
|
||||||
|
|
||||||
Thanks to everyone that has submitted ideas, bug reports, helped debugging or
|
|
||||||
came up with solutions on gibhub, bitbucket, and through email.
|
|
||||||
|
|
||||||
===============================================================================
|
|
||||||
8. Extending ctrlp *ctrlp-extensions*
|
|
||||||
|
|
||||||
Extending |CtrlP| is incredibly simple. Just create a .vim file following a
|
|
||||||
guidelines, place it in the right spot, add a line to your .vimrc, and you have
|
|
||||||
an extension.
|
|
||||||
|
|
||||||
To see how it all works, get the sample.vim from the 'extensions' branch on the
|
To see how it all works, get the sample.vim from the 'extensions' branch on the
|
||||||
git repository (https://github.com/kien/ctrlp.vim/tree/extensions), and place
|
git repository (https://github.com/kien/ctrlp.vim/tree/extensions), and place
|
||||||
@ -514,7 +475,30 @@ A 4th search type will show up the next time you open |CtrlP|.
|
|||||||
For more details, check out the comments inside sample.vim.
|
For more details, check out the comments inside sample.vim.
|
||||||
|
|
||||||
===============================================================================
|
===============================================================================
|
||||||
9. Changelog *ctrlp-changelog*
|
CREDITS *ctrlp-credits*
|
||||||
|
|
||||||
|
Developed by Kien Nguyen (github.com/kien), primarily based on the Command-T
|
||||||
|
and the LustyExplorer plugins. No code was taken from these plugins, but I did
|
||||||
|
clone the majority of their (awesome) interfaces and the way they work.
|
||||||
|
|
||||||
|
The was originally written as a module for a would-be larger plugin called
|
||||||
|
AutoDoc.vim which I’ve stopped developing because of lost of interest. I really
|
||||||
|
liked the way Command-T and LustyExplorer deal with user’s input, so I wrote a
|
||||||
|
pure Vimscript version of their prompt window, intended to use it for the
|
||||||
|
aforementioned plugin.
|
||||||
|
|
||||||
|
Homepage: http://kien.github.com/ctrlp.vim
|
||||||
|
Git repository: https://github.com/kien/ctrlp.vim
|
||||||
|
Mercurial repository: https://bitbucket.org/kien/ctrlp.vim
|
||||||
|
|
||||||
|
===============================================================================
|
||||||
|
THANKS *ctrlp-thanks*
|
||||||
|
|
||||||
|
Thanks to everyone that has submitted ideas, bug reports, helped debugging or
|
||||||
|
came up with solutions on gibhub, bitbucket, and through email.
|
||||||
|
|
||||||
|
===============================================================================
|
||||||
|
CHANGELOG *ctrlp-changelog*
|
||||||
|
|
||||||
Before 2011/10/30
|
Before 2011/10/30
|
||||||
|
|
||||||
|
@ -10,7 +10,8 @@ Full path fuzzy __file__, __buffer__ and __MRU__ file finder for Vim.
|
|||||||
![ctrlp][1]
|
![ctrlp][1]
|
||||||
|
|
||||||
## Basic Usage
|
## Basic Usage
|
||||||
* Press `<c-p>` or run `:CtrlP` to invoke CtrlP.
|
* Press `<c-p>` or run `:CtrlP` to invoke CtrlP in find file mode.
|
||||||
|
* Use `:CtrlPBuffer` and `:CtrlPMRU` for buffer and MRU mode.
|
||||||
|
|
||||||
Once CtrlP is open:
|
Once CtrlP is open:
|
||||||
|
|
||||||
@ -34,7 +35,7 @@ e.g. `abc:45` will open the file matched the pattern and jump to line 45.
|
|||||||
* When CtrlP is invoked, it automatically sets the working directory according to this variable:
|
* When CtrlP is invoked, it automatically sets the working directory according to this variable:
|
||||||
|
|
||||||
```vim
|
```vim
|
||||||
let g:ctrlp_working_path_mode = 1
|
let g:ctrlp_working_path_mode = 2
|
||||||
```
|
```
|
||||||
|
|
||||||
0 - don’t manage working directory.
|
0 - don’t manage working directory.
|
||||||
@ -63,7 +64,7 @@ The parameter is the same (0, 1 or 2):
|
|||||||
```
|
```
|
||||||
|
|
||||||
* 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`.
|
||||||
e.g. Just have something like this in your vimrc:
|
Examples:
|
||||||
|
|
||||||
```vim
|
```vim
|
||||||
set wildignore+=*/.git/*,*/.hg/*,*/.svn/* " for Linux/MacOSX
|
set wildignore+=*/.git/*,*/.hg/*,*/.svn/* " for Linux/MacOSX
|
||||||
|
Loading…
Reference in New Issue
Block a user