option to limit the number of files; no <esc> in term
This commit is contained in:
parent
e311264c38
commit
1c7c0ffae7
@ -128,6 +128,13 @@ else
|
||||
unl g:ctrlp_highlight_match
|
||||
endif
|
||||
|
||||
if !exists('g:ctrlp_max_files')
|
||||
let s:maxfiles = 20000
|
||||
else
|
||||
let s:maxfiles = g:ctrlp_max_files
|
||||
unl g:ctrlp_max_files
|
||||
endif
|
||||
|
||||
if !exists('g:ctrlp_user_command')
|
||||
let g:ctrlp_user_command = ''
|
||||
endif
|
||||
@ -169,7 +176,7 @@ func! s:List(dirs, allfiles)
|
||||
let alldirs = s:dotfiles ? filter(entries, 's:dirfilter(v:val)') : filter(entries, 'isdirectory(v:val)')
|
||||
let allfiles = filter(entries2, '!isdirectory(v:val)')
|
||||
cal extend(allfiles, a:allfiles, 0)
|
||||
if empty(alldirs)
|
||||
if empty(alldirs) || s:maxfiles(len(allfiles))
|
||||
let s:allfiles = allfiles
|
||||
else
|
||||
let dirs = join(alldirs, ',')
|
||||
@ -321,7 +328,7 @@ func! s:SetupBlank() "{{{
|
||||
setl cul
|
||||
setl nocuc
|
||||
setl tw=0
|
||||
setl wfw
|
||||
setl wfh
|
||||
if v:version >= '703'
|
||||
setl nornu
|
||||
setl noudf
|
||||
@ -679,7 +686,11 @@ func! s:MapSpecs(...)
|
||||
endfor | endfor
|
||||
else
|
||||
for each in keys(prtmaps) | for kp in prtmaps[each]
|
||||
exe 'nn <buffer> <silent>' kp ':cal <SID>'.each.'<cr>'
|
||||
if kp == '<esc>' && ( &term =~? 'xterm' || &term =~? '^vt' )
|
||||
" do nothing
|
||||
else
|
||||
exe 'nn <buffer> <silent>' kp ':cal <SID>'.each.'<cr>'
|
||||
endif
|
||||
endfor | endfor
|
||||
endif
|
||||
endfunc
|
||||
@ -824,6 +835,10 @@ func! s:AcceptSelection(mode,...) "{{{
|
||||
endif
|
||||
endfor
|
||||
" switch to the buffer or open the file
|
||||
let opened = 0
|
||||
if s:normbuf()
|
||||
exe s:normbuf().'winc w'
|
||||
endif
|
||||
if bufnum > 0
|
||||
if exists('buftabwinnr')
|
||||
exe 'norm!' buftabnr.'gt'
|
||||
@ -831,11 +846,18 @@ func! s:AcceptSelection(mode,...) "{{{
|
||||
elseif bufwinnr > 0
|
||||
exe bufwinnr.'winc w'
|
||||
else
|
||||
exe 'b' bufnum
|
||||
if !s:normbuf()
|
||||
exe 'bo vne'
|
||||
endif
|
||||
let cmd = 'b'.bufnum
|
||||
endif
|
||||
else
|
||||
exe 'bo '.cmd.' '.filpath
|
||||
if !s:normbuf() | if md == 'e'
|
||||
exe 'bo vne'
|
||||
endif | endif
|
||||
let cmd = 'bo '.cmd.' '.filpath
|
||||
endif
|
||||
exe cmd
|
||||
" jump to line
|
||||
if exists('s:jmpln') && !empty('s:jmpln')
|
||||
exe s:jmpln
|
||||
@ -926,11 +948,14 @@ func! s:statusline(...)
|
||||
let byfname = '%#Character#\ '.byfname.'\ %*'
|
||||
let item = '%#Character#\ '.item.'\ %*'
|
||||
let slider = '\ <'.prev.'>={'.item.'}=<'.next.'>'
|
||||
exe 'setl stl='.focus.byfname.regex.slider
|
||||
let dir = '\ %#LineNr#\ '.escape(getcwd(), ' =#(){}%\').'\ %*'
|
||||
exe 'setl stl='.focus.byfname.regex.slider.dir
|
||||
endfunc
|
||||
|
||||
func! s:progress(len)
|
||||
exe 'setl stl=%#Function#\ '.a:len.'\ %*\ '
|
||||
let dir = '%#LineNr#\ Scanning:\ '.escape(getcwd(), ' =#(){}%\').'\ %*'
|
||||
let cnt = '%#Function#\ '.a:len.'\ %*'
|
||||
exe 'setl stl='.dir.cnt
|
||||
redr
|
||||
endfunc
|
||||
"}}}
|
||||
@ -993,6 +1018,26 @@ endfunc
|
||||
func! s:matchsubstr(item, pat)
|
||||
retu match(split(a:item, '[\/]\ze[^\/]\+$')[-1], a:pat)
|
||||
endfunc
|
||||
|
||||
func! s:maxfiles(len)
|
||||
if !s:maxfiles
|
||||
retu 0
|
||||
elseif s:maxfiles && a:len > s:maxfiles
|
||||
retu 1
|
||||
endif
|
||||
endfunc
|
||||
|
||||
" return the first window number with a normal buffer
|
||||
func! s:normbuf()
|
||||
if &l:bl && empty(&l:bt) && &l:ma
|
||||
retu winnr()
|
||||
endif
|
||||
for each in range(1, winnr('$'))
|
||||
winc w
|
||||
if &l:bl && empty(&l:bt) && &l:ma | retu each | endif
|
||||
endfor
|
||||
retu 0
|
||||
endfunc
|
||||
"}}}
|
||||
"}}}
|
||||
|
||||
|
@ -207,6 +207,12 @@ the highlight group that’ll be used: >
|
||||
let g:ctrlp_highlight_match = [1, 'Function']
|
||||
<
|
||||
|
||||
*'g:ctrlp_max_files'*
|
||||
The maximum number of files to scan, set this to a higher number if your hard
|
||||
drives are fast (SSDs, RAID 0, or both) and you work with large projects: >
|
||||
let g:ctrlp_max_files = 20000
|
||||
<
|
||||
|
||||
*'g:ctrlp_user_command'*
|
||||
Specify an external tool to use for indexing files instead of Vim’s globpath().
|
||||
Use %s in place of the target directory: >
|
||||
@ -346,7 +352,11 @@ Once inside the prompt:
|
||||
<esc>,
|
||||
<c-c>,
|
||||
<c-g>
|
||||
Exit |CtrlP|
|
||||
Exit |CtrlP|.
|
||||
|
||||
Note: The <esc> (also <c-[>) mapping isn’t available in terminal. Use <c-c>
|
||||
or <c-g> to exit |CtrlP| instead.
|
||||
http://linux.die.net/man/4/console_codes
|
||||
|
||||
Chose your own mappings with |g:ctrlp_prompt_mappings|.
|
||||
|
||||
@ -399,6 +409,9 @@ Mercurial repository: https://bitbucket.org/kien/ctrlp.vim
|
||||
===============================================================================
|
||||
CHANGELOG
|
||||
|
||||
+ Remove <esc> mapping in term.
|
||||
+ New option: |g:ctrlp_max_files|
|
||||
|
||||
Before 2011/09/12
|
||||
|
||||
+ Ability to cycle through matched lines in the match window.
|
||||
|
Loading…
Reference in New Issue
Block a user