Improve <tab> completion

Refs #77
This commit is contained in:
Kien N 2012-01-18 20:56:18 +07:00
parent d1a64232ad
commit f1db1253ec
3 changed files with 16 additions and 21 deletions

View File

@ -497,13 +497,11 @@ fu! s:PrtExpandDir()
if prt[0] == '' | retu | en if prt[0] == '' | retu | en
let parts = split(prt[0], '[\/]\ze[^\/]\+[\/:]\?$') let parts = split(prt[0], '[\/]\ze[^\/]\+[\/:]\?$')
if len(parts) == 1 if len(parts) == 1
let seed = parts[0] let [base, seed] = ['', parts[0]]
let begin = '' elsei len(parts) == 2
elsei len(parts) > 1 let [base, seed] = parts
let seed = parts[1]
let begin = parts[0].s:lash
en en
let dirs = s:dircompl(begin, seed) let dirs = s:dircompl(base, seed)
if len(dirs) == 1 if len(dirs) == 1
let prt[0] = dirs[0] let prt[0] = dirs[0]
elsei len(dirs) > 1 elsei len(dirs) > 1
@ -984,16 +982,12 @@ fu! ctrlp#progress(enum)
redr redr
endf endf
" Paths {{{2 " Paths {{{2
fu! s:dircompl(dir, seed) fu! s:dircompl(be, sd)
if a:seed == '' | retu [] | en if a:sd == '' | retu [] | en
let [dir, seed] = a:dir == '' let [be, sd] = a:be == '' ? [getcwd(), a:sd] : [a:be, a:be.s:lash.a:sd]
\ ? [getcwd().s:lash, a:seed] : [a:dir, a:dir.a:seed] let dirs = ctrlp#rmbasedir(split(globpath(be, a:sd.'*/'), "\n"))
let dirs = ctrlp#rmbasedir(split(globpath(dir, '*/'), "\n")) cal filter(dirs, '!match(v:val, escape(sd, ''~$.\''))'
if s:dotfiles \ . ' && match(v:val, ''\v(^|[\/])\.{1,2}[\/]$'') < 0')
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 retu dirs
endf endf
@ -1023,7 +1017,7 @@ fu! ctrlp#dirnfile(entries)
let etype = getftype(each) let etype = getftype(each)
if s:igntype >= 0 && s:usrign(each, etype) | con | en if s:igntype >= 0 && s:usrign(each, etype) | con | en
if etype == 'dir' if etype == 'dir'
if s:dotfiles | if match(each, '[\/]\.\{,2}$') < 0 if s:dotfiles | if match(each, '[\/]\.\{1,2}$') < 0
cal add(items[0], each) cal add(items[0], each)
en | el en | el
cal add(items[0], each) cal add(items[0], each)
@ -1100,7 +1094,7 @@ fu! s:findroot(curr, mark, depth, type)
endf endf
fu! s:glbpath(...) fu! s:glbpath(...)
let cond = ( v:version == 702 && has('patch051') ) || v:version > 702 let cond = v:version > 702 || ( v:version == 702 && has('patch051') )
retu call('globpath', cond ? a:000 : a:000[:1]) retu call('globpath', cond ? a:000 : a:000[:1])
endf endf

View File

@ -61,7 +61,7 @@ fu! ctrlp#utils#writecache(lines, ...)
endf endf
fu! ctrlp#utils#glob(...) fu! ctrlp#utils#glob(...)
let cond = ( v:version == 702 && has('patch051') ) || v:version > 702 let cond = v:version > 702 || ( v:version == 702 && has('patch051') )
retu call('glob', cond ? a:000 : [a:1]) retu call('glob', cond ? a:000 : [a:1])
endf endf
"}}} "}}}

View File

@ -18,6 +18,7 @@ Once CtrlP is open:
* Press `<c-f>` and `<c-b>` to switch between find file, buffer, and MRU file modes. * Press `<c-f>` and `<c-b>` to switch between find file, buffer, and MRU file modes.
* Press `<c-d>` to switch to filename only search instead of full path. * Press `<c-d>` to switch to filename only search instead of full path.
* Press `<F5>` to purge the cache for the current directory and get new files.
* Use `*` or `|` in the prompt to submit the string as a Vims regexp pattern. * Use `*` or `|` in the prompt to submit the string as a Vims regexp pattern.
* Or press `<c-r>` to switch to regexp mode. * Or press `<c-r>` to switch to regexp mode.
* End the input string with a colon `:` followed by a command to execute after opening the file. * End the input string with a colon `:` followed by a command to execute after opening the file.
@ -61,7 +62,7 @@ Examples:
let g:ctrlp_custom_ignore = { let g:ctrlp_custom_ignore = {
\ 'dir': '\.git$\|\.hg$\|\.svn$', \ 'dir': '\.git$\|\.hg$\|\.svn$',
\ 'file': '\.exe$\|\.so$\|\.dll$', \ 'file': '\.exe$\|\.so$\|\.dll$',
\ 'link': 'bad_symbolic_link', \ 'link': 'some_bad_symbolic_links',
\ } \ }
``` ```