parent
faaaf519a6
commit
b3b8f7beae
@ -44,7 +44,6 @@ fu! s:opts()
|
|||||||
exe 'let' va[0] '=' string(exists(ke) ? eval(ke) : va[1])
|
exe 'let' va[0] '=' string(exists(ke) ? eval(ke) : va[1])
|
||||||
endfo
|
endfo
|
||||||
if !exists('g:ctrlp_newcache') | let g:ctrlp_newcache = 0 | en
|
if !exists('g:ctrlp_newcache') | let g:ctrlp_newcache = 0 | en
|
||||||
let s:glob = s:dotfiles ? '.*\|*' : '*'
|
|
||||||
let s:maxdepth = min([s:maxdepth, 100])
|
let s:maxdepth = min([s:maxdepth, 100])
|
||||||
let s:igntype = empty(s:usrign) ? -1 : type(s:usrign)
|
let s:igntype = empty(s:usrign) ? -1 : type(s:usrign)
|
||||||
" Extensions
|
" Extensions
|
||||||
@ -66,11 +65,12 @@ fu! s:opts()
|
|||||||
\ 'AcceptSelection("h")': ['<c-x>', '<c-cr>', '<c-s>'],
|
\ 'AcceptSelection("h")': ['<c-x>', '<c-cr>', '<c-s>'],
|
||||||
\ 'AcceptSelection("t")': ['<c-t>', '<MiddleMouse>'],
|
\ 'AcceptSelection("t")': ['<c-t>', '<MiddleMouse>'],
|
||||||
\ 'AcceptSelection("v")': ['<c-v>', '<RightMouse>'],
|
\ 'AcceptSelection("v")': ['<c-v>', '<RightMouse>'],
|
||||||
\ 'ToggleFocus()': ['<tab>', '<c-i>'],
|
\ 'ToggleFocus()': ['<s-tab>'],
|
||||||
\ 'ToggleRegex()': ['<c-r>'],
|
\ 'ToggleRegex()': ['<c-r>'],
|
||||||
\ 'ToggleByFname()': ['<c-d>'],
|
\ 'ToggleByFname()': ['<c-d>'],
|
||||||
\ 'ToggleType(1)': ['<c-f>', '<c-up>'],
|
\ 'ToggleType(1)': ['<c-f>', '<c-up>'],
|
||||||
\ 'ToggleType(-1)': ['<c-b>', '<c-down>'],
|
\ 'ToggleType(-1)': ['<c-b>', '<c-down>'],
|
||||||
|
\ 'PrtExpandDir()': ['<tab>', '<c-i>'],
|
||||||
\ 'PrtInsert("w")': ['<F2>'],
|
\ 'PrtInsert("w")': ['<F2>'],
|
||||||
\ 'PrtInsert("s")': ['<F3>'],
|
\ 'PrtInsert("s")': ['<F3>'],
|
||||||
\ 'PrtInsert("v")': ['<F4>'],
|
\ 'PrtInsert("v")': ['<F4>'],
|
||||||
@ -224,7 +224,10 @@ fu! s:Files()
|
|||||||
endf
|
endf
|
||||||
|
|
||||||
fu! s:GlobPath(dirs, depth)
|
fu! s:GlobPath(dirs, depth)
|
||||||
let entries = split(globpath(a:dirs, s:glob), "\n")
|
let entries = split(globpath(a:dirs, '*'), "\n")
|
||||||
|
if s:dotfiles
|
||||||
|
let entries += split(globpath(a:dirs, '.*'), "\n")
|
||||||
|
en
|
||||||
let [dnf, depth] = [ctrlp#dirnfile(entries), a:depth + 1]
|
let [dnf, depth] = [ctrlp#dirnfile(entries), a:depth + 1]
|
||||||
cal extend(g:ctrlp_allfiles, dnf[1])
|
cal extend(g:ctrlp_allfiles, dnf[1])
|
||||||
if !empty(dnf[0]) && !s:maxf(len(g:ctrlp_allfiles)) && depth <= s:maxdepth
|
if !empty(dnf[0]) && !s:maxf(len(g:ctrlp_allfiles)) && depth <= s:maxdepth
|
||||||
@ -487,6 +490,26 @@ fu! s:PrtInsert(type)
|
|||||||
\ : a:type == '+' ? substitute(getreg('+'), '\n', '\\n', 'g') : s:prompt[0]
|
\ : a:type == '+' ? substitute(getreg('+'), '\n', '\\n', 'g') : s:prompt[0]
|
||||||
cal s:BuildPrompt(1)
|
cal s:BuildPrompt(1)
|
||||||
endf
|
endf
|
||||||
|
|
||||||
|
fu! s:PrtExpandDir()
|
||||||
|
let prt = s:prompt
|
||||||
|
if prt[0] == '' | retu | en
|
||||||
|
let parts = split(prt[0], '[\/]\ze[^\/]\+[\/:]\?$')
|
||||||
|
if len(parts) == 1
|
||||||
|
let seed = parts[0]
|
||||||
|
let begin = ''
|
||||||
|
elsei len(parts) > 1
|
||||||
|
let seed = parts[1]
|
||||||
|
let begin = parts[0].s:lash
|
||||||
|
en
|
||||||
|
let dirs = s:dircompl(begin, seed)
|
||||||
|
if len(dirs) == 1
|
||||||
|
let prt[0] = dirs[0]
|
||||||
|
elsei len(dirs) > 1
|
||||||
|
let prt[0] .= s:findcommon(dirs, prt[0])
|
||||||
|
en
|
||||||
|
cal s:BuildPrompt(1)
|
||||||
|
endf
|
||||||
" Movement {{{2
|
" Movement {{{2
|
||||||
fu! s:PrtCurLeft()
|
fu! s:PrtCurLeft()
|
||||||
if !empty(s:prompt[0])
|
if !empty(s:prompt[0])
|
||||||
@ -960,6 +983,33 @@ fu! ctrlp#progress(enum)
|
|||||||
redr
|
redr
|
||||||
endf
|
endf
|
||||||
" Paths {{{2
|
" Paths {{{2
|
||||||
|
fu! s:dircompl(dir, seed)
|
||||||
|
if a:seed == '' | retu [] | en
|
||||||
|
let [dir, seed] = a:dir == ''
|
||||||
|
\ ? [getcwd().s:lash, a:seed] : [a:dir, a:dir.a:seed]
|
||||||
|
let dirs = ctrlp#rmbasedir(split(globpath(dir, '*/'), "\n"))
|
||||||
|
if s:dotfiles
|
||||||
|
let dirs += ctrlp#rmbasedir(split(globpath(dir, '.*/'), "\n"))
|
||||||
|
en
|
||||||
|
cal filter(dirs, '!match(v:val, escape(seed, ''''''~$.\'')) && ( !s:dotfiles'
|
||||||
|
\ . ' || ( s:dotfiles && match(v:val, ''[\/]\.\{,2}[\/:]$'') < 0) )')
|
||||||
|
retu dirs
|
||||||
|
endf
|
||||||
|
|
||||||
|
fu! s:findcommon(items, seed)
|
||||||
|
let [items, id, cmn, ic] = [copy(a:items), strlen(a:seed), '', 0]
|
||||||
|
cal map(items, 'strpart(v:val, id)')
|
||||||
|
for char in split(items[0], '\zs')
|
||||||
|
for item in items[1:]
|
||||||
|
if item[ic] != char | let brk = 1 | brea | en
|
||||||
|
endfo
|
||||||
|
if exists('brk') | brea | en
|
||||||
|
let cmn .= char
|
||||||
|
let ic += 1
|
||||||
|
endfo
|
||||||
|
retu cmn
|
||||||
|
endf
|
||||||
|
|
||||||
fu! s:ispathitem()
|
fu! s:ispathitem()
|
||||||
let ext = s:itemtype - ( g:ctrlp_builtins + 1 )
|
let ext = s:itemtype - ( g:ctrlp_builtins + 1 )
|
||||||
retu s:itemtype < 3
|
retu s:itemtype < 3
|
||||||
|
@ -14,7 +14,7 @@ let s:ars = [
|
|||||||
\ 's:maxdepth',
|
\ 's:maxdepth',
|
||||||
\ 's:maxfiles',
|
\ 's:maxfiles',
|
||||||
\ 's:compare_lim',
|
\ 's:compare_lim',
|
||||||
\ 's:glob',
|
\ 's:dotfiles',
|
||||||
\ ]
|
\ ]
|
||||||
|
|
||||||
let s:dir_var = {
|
let s:dir_var = {
|
||||||
@ -31,7 +31,10 @@ let g:ctrlp_ext_vars = exists('g:ctrlp_ext_vars') && !empty(g:ctrlp_ext_vars)
|
|||||||
let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars)
|
let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars)
|
||||||
" Utilities {{{1
|
" Utilities {{{1
|
||||||
fu! s:globdirs(dirs, depth)
|
fu! s:globdirs(dirs, depth)
|
||||||
let entries = split(globpath(a:dirs, s:glob), "\n")
|
let entries = split(globpath(a:dirs, '*'), "\n")
|
||||||
|
if s:dotfiles
|
||||||
|
let entries += split(globpath(a:dirs, '.*'), "\n")
|
||||||
|
en
|
||||||
let [dirs, depth] = [ctrlp#dirnfile(entries)[0], a:depth + 1]
|
let [dirs, depth] = [ctrlp#dirnfile(entries)[0], a:depth + 1]
|
||||||
cal extend(g:ctrlp_alldirs, dirs)
|
cal extend(g:ctrlp_alldirs, dirs)
|
||||||
if !empty(dirs) && !s:max(len(g:ctrlp_alldirs), s:maxfiles)
|
if !empty(dirs) && !s:max(len(g:ctrlp_alldirs), s:maxfiles)
|
||||||
|
@ -142,11 +142,12 @@ only need to keep the lines that you’ve changed the values (inside []): >
|
|||||||
\ 'AcceptSelection("h")': ['<c-x>', '<c-cr>', '<c-s>'],
|
\ 'AcceptSelection("h")': ['<c-x>', '<c-cr>', '<c-s>'],
|
||||||
\ 'AcceptSelection("t")': ['<c-t>', '<MiddleMouse>'],
|
\ 'AcceptSelection("t")': ['<c-t>', '<MiddleMouse>'],
|
||||||
\ 'AcceptSelection("v")': ['<c-v>', '<RightMouse>'],
|
\ 'AcceptSelection("v")': ['<c-v>', '<RightMouse>'],
|
||||||
\ 'ToggleFocus()': ['<tab>', '<c-i>'],
|
\ 'ToggleFocus()': ['<s-tab>'],
|
||||||
\ 'ToggleRegex()': ['<c-r>'],
|
\ 'ToggleRegex()': ['<c-r>'],
|
||||||
\ 'ToggleByFname()': ['<c-d>'],
|
\ 'ToggleByFname()': ['<c-d>'],
|
||||||
\ 'ToggleType(1)': ['<c-f>', '<c-up>'],
|
\ 'ToggleType(1)': ['<c-f>', '<c-up>'],
|
||||||
\ 'ToggleType(-1)': ['<c-b>', '<c-down>'],
|
\ 'ToggleType(-1)': ['<c-b>', '<c-down>'],
|
||||||
|
\ 'PrtExpandDir()': ['<tab>', '<c-i>'],
|
||||||
\ 'PrtInsert("w")': ['<F2>'],
|
\ 'PrtInsert("w")': ['<F2>'],
|
||||||
\ 'PrtInsert("s")': ['<F3>'],
|
\ 'PrtInsert("s")': ['<F3>'],
|
||||||
\ 'PrtInsert("v")': ['<F4>'],
|
\ 'PrtInsert("v")': ['<F4>'],
|
||||||
@ -443,6 +444,10 @@ Once inside the prompt:~
|
|||||||
Scroll to the 'previous' search mode in the sequence.
|
Scroll to the 'previous' search mode in the sequence.
|
||||||
|
|
||||||
<tab>
|
<tab>
|
||||||
|
Auto-complete directory names under the current working directory inside
|
||||||
|
the prompt.
|
||||||
|
|
||||||
|
<s-tab>
|
||||||
Toggle the focus between the match window and the prompt.
|
Toggle the focus between the match window and the prompt.
|
||||||
|
|
||||||
<c-j>,
|
<c-j>,
|
||||||
@ -738,6 +743,8 @@ CHANGELOG *ctrlp-changelog*
|
|||||||
|
|
||||||
Before 2012/01/15~
|
Before 2012/01/15~
|
||||||
|
|
||||||
|
+ New mapping: Switch <tab> and <s-tab>. <tab> is now used for completion
|
||||||
|
of directory names under the current working directory.
|
||||||
+ New options: |g:ctrlp_arg_map| for <c-y>, <c-o> to accept an argument.
|
+ New options: |g:ctrlp_arg_map| for <c-y>, <c-o> to accept an argument.
|
||||||
|g:ctrlp_status_func| custom statusline.
|
|g:ctrlp_status_func| custom statusline.
|
||||||
|g:ctrlp_mruf_relative| show only MRU files inside cwd.
|
|g:ctrlp_mruf_relative| show only MRU files inside cwd.
|
||||||
|
@ -55,7 +55,7 @@ if index(s:ext, 'buffertag') >= 0
|
|||||||
com! CtrlPBufTagAll cal ctrlp#init(ctrlp#buffertag#cmd(1))
|
com! CtrlPBufTagAll cal ctrlp#init(ctrlp#buffertag#cmd(1))
|
||||||
en
|
en
|
||||||
|
|
||||||
if index(s:ext, 'rts') >= 0
|
if index(s:ext, 'rtscript') >= 0
|
||||||
com! CtrlPRTS cal ctrlp#init(ctrlp#rtscript#id())
|
com! CtrlPRTS cal ctrlp#init(ctrlp#rtscript#id())
|
||||||
en
|
en
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user