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

View File

@ -61,8 +61,8 @@ fu! ctrlp#utils#writecache(lines, ...)
endf
fu! ctrlp#utils#glob(...)
let cond = ( v:version == 702 && has('patch051') ) || v:version > 702
retu call('glob', cond ? a:000 : [a:1])
let cond = v:version > 702 || ( v:version == 702 && has('patch051') )
retu call('glob', cond ? a:000 : [a:1])
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-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.
* 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.
@ -61,7 +62,7 @@ Examples:
let g:ctrlp_custom_ignore = {
\ 'dir': '\.git$\|\.hg$\|\.svn$',
\ 'file': '\.exe$\|\.so$\|\.dll$',
\ 'link': 'bad_symbolic_link',
\ 'link': 'some_bad_symbolic_links',
\ }
```