Squashed 'vim/bundle/ctrlp/' content from commit bd0cb64d2

git-subtree-dir: vim/bundle/ctrlp
git-subtree-split: bd0cb64d22231716534dc7fdfed4906560c78c4e
Buddy Sandidge 11 years ago
commit a3f4f31c41

6
.gitignore vendored

@ -0,0 +1,6 @@
*.markdown
*.zip
note.txt
tags
.hg*
tmp/*

File diff suppressed because it is too large Load Diff

@ -0,0 +1,140 @@
" =============================================================================
" File: autoload/ctrlp/bookmarkdir.vim
" Description: Bookmarked directories extension
" Author: Kien Nguyen <github.com/kien>
" =============================================================================
" Init {{{1
if exists('g:loaded_ctrlp_bookmarkdir') && g:loaded_ctrlp_bookmarkdir
fini
en
let g:loaded_ctrlp_bookmarkdir = 1
cal add(g:ctrlp_ext_vars, {
\ 'init': 'ctrlp#bookmarkdir#init()',
\ 'accept': 'ctrlp#bookmarkdir#accept',
\ 'lname': 'bookmarked dirs',
\ 'sname': 'bkd',
\ 'type': 'tabs',
\ 'opmul': 1,
\ 'nolim': 1,
\ 'wipe': 'ctrlp#bookmarkdir#remove',
\ })
let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars)
" Utilities {{{1
fu! s:getinput(str, ...)
echoh Identifier
cal inputsave()
let input = call('input', a:0 ? [a:str] + a:000 : [a:str])
cal inputrestore()
echoh None
retu input
endf
fu! s:cachefile()
if !exists('s:cadir') || !exists('s:cafile')
let s:cadir = ctrlp#utils#cachedir().ctrlp#utils#lash().'bkd'
let s:cafile = s:cadir.ctrlp#utils#lash().'cache.txt'
en
retu s:cafile
endf
fu! s:writecache(lines)
cal ctrlp#utils#writecache(a:lines, s:cadir, s:cafile)
endf
fu! s:getbookmarks()
retu ctrlp#utils#readfile(s:cachefile())
endf
fu! s:savebookmark(name, cwd)
let cwds = exists('+ssl') ? [tr(a:cwd, '\', '/'), tr(a:cwd, '/', '\')] : [a:cwd]
let entries = filter(s:getbookmarks(), 'index(cwds, s:parts(v:val)[1]) < 0')
cal s:writecache(insert(entries, a:name.' '.a:cwd))
endf
fu! s:setentries()
let time = getftime(s:cachefile())
if !( exists('s:bookmarks') && time == s:bookmarks[0] )
let s:bookmarks = [time, s:getbookmarks()]
en
endf
fu! s:parts(str)
let mlist = matchlist(a:str, '\v([^\t]+)\t(.*)$')
retu mlist != [] ? mlist[1:2] : ['', '']
endf
fu! s:process(entries, type)
retu map(a:entries, 's:modify(v:val, a:type)')
endf
fu! s:modify(entry, type)
let [name, dir] = s:parts(a:entry)
let dir = fnamemodify(dir, a:type)
retu name.' '.( dir == '' ? '.' : dir )
endf
fu! s:msg(name, cwd)
redr
echoh Identifier | echon 'Bookmarked ' | echoh Constant
echon a:name.' ' | echoh Directory | echon a:cwd
echoh None
endf
fu! s:syntax()
if !ctrlp#nosy()
cal ctrlp#hicheck('CtrlPBookmark', 'Identifier')
cal ctrlp#hicheck('CtrlPTabExtra', 'Comment')
sy match CtrlPBookmark '^> [^\t]\+' contains=CtrlPLinePre
sy match CtrlPTabExtra '\zs\t.*\ze$'
en
endf
" Public {{{1
fu! ctrlp#bookmarkdir#init()
cal s:setentries()
cal s:syntax()
retu s:process(copy(s:bookmarks[1]), ':.')
endf
fu! ctrlp#bookmarkdir#accept(mode, str)
let parts = s:parts(s:modify(a:str, ':p'))
cal call('s:savebookmark', parts)
if a:mode =~ 't\|v\|h'
cal ctrlp#exit()
en
cal ctrlp#setdir(parts[1], a:mode =~ 't\|h' ? 'chd!' : 'lc!')
if a:mode == 'e'
cal ctrlp#switchtype(0)
cal ctrlp#recordhist()
cal ctrlp#prtclear()
en
endf
fu! ctrlp#bookmarkdir#add(dir)
let str = 'Directory to bookmark: '
let cwd = a:dir != '' ? a:dir : s:getinput(str, getcwd(), 'dir')
if cwd == '' | retu | en
let cwd = fnamemodify(cwd, ':p')
let name = s:getinput('Bookmark as: ', cwd)
if name == '' | retu | en
let name = tr(name, ' ', ' ')
cal s:savebookmark(name, cwd)
cal s:msg(name, cwd)
endf
fu! ctrlp#bookmarkdir#remove(entries)
cal s:process(a:entries, ':p')
cal s:writecache(a:entries == [] ? [] :
\ filter(s:getbookmarks(), 'index(a:entries, v:val) < 0'))
cal s:setentries()
retu s:process(copy(s:bookmarks[1]), ':.')
endf
fu! ctrlp#bookmarkdir#id()
retu s:id
endf
"}}}
" vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2

@ -0,0 +1,261 @@
" =============================================================================
" File: autoload/ctrlp/buffertag.vim
" Description: Buffer Tag extension
" Maintainer: Kien Nguyen <github.com/kien>
" Credits: Much of the code was taken from tagbar.vim by Jan Larres, plus
" a few lines from taglist.vim by Yegappan Lakshmanan and from
" buffertag.vim by Takeshi Nishida.
" =============================================================================
" Init {{{1
if exists('g:loaded_ctrlp_buftag') && g:loaded_ctrlp_buftag
fini
en
let g:loaded_ctrlp_buftag = 1
cal add(g:ctrlp_ext_vars, {
\ 'init': 'ctrlp#buffertag#init(s:crfile)',
\ 'accept': 'ctrlp#buffertag#accept',
\ 'lname': 'buffer tags',
\ 'sname': 'bft',
\ 'exit': 'ctrlp#buffertag#exit()',
\ 'type': 'tabs',
\ 'opts': 'ctrlp#buffertag#opts()',
\ })
let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars)
let [s:pref, s:opts] = ['g:ctrlp_buftag_', {
\ 'systemenc': ['s:enc', &enc],
\ 'ctags_bin': ['s:bin', ''],
\ 'types': ['s:usr_types', {}],
\ }]
let s:bins = [
\ 'ctags-exuberant',
\ 'exuberant-ctags',
\ 'exctags',
\ '/usr/local/bin/ctags',
\ '/opt/local/bin/ctags',
\ 'ctags',
\ 'ctags.exe',
\ 'tags',
\ ]
let s:types = {
\ 'asm' : '%sasm%sasm%sdlmt',
\ 'aspperl': '%sasp%sasp%sfsv',
\ 'aspvbs' : '%sasp%sasp%sfsv',
\ 'awk' : '%sawk%sawk%sf',
\ 'beta' : '%sbeta%sbeta%sfsv',
\ 'c' : '%sc%sc%sdgsutvf',
\ 'cpp' : '%sc++%sc++%snvdtcgsuf',
\ 'cs' : '%sc#%sc#%sdtncEgsipm',
\ 'cobol' : '%scobol%scobol%sdfgpPs',
\ 'eiffel' : '%seiffel%seiffel%scf',
\ 'erlang' : '%serlang%serlang%sdrmf',
\ 'expect' : '%stcl%stcl%scfp',
\ 'fortran': '%sfortran%sfortran%spbceiklmntvfs',
\ 'html' : '%shtml%shtml%saf',
\ 'java' : '%sjava%sjava%spcifm',
\ 'javascript': '%sjavascript%sjavascript%sf',
\ 'lisp' : '%slisp%slisp%sf',
\ 'lua' : '%slua%slua%sf',
\ 'make' : '%smake%smake%sm',
\ 'pascal' : '%spascal%spascal%sfp',
\ 'perl' : '%sperl%sperl%sclps',
\ 'php' : '%sphp%sphp%scdvf',
\ 'python' : '%spython%spython%scmf',
\ 'rexx' : '%srexx%srexx%ss',
\ 'ruby' : '%sruby%sruby%scfFm',
\ 'scheme' : '%sscheme%sscheme%ssf',
\ 'sh' : '%ssh%ssh%sf',
\ 'csh' : '%ssh%ssh%sf',
\ 'zsh' : '%ssh%ssh%sf',
\ 'slang' : '%sslang%sslang%snf',
\ 'sml' : '%ssml%ssml%secsrtvf',
\ 'sql' : '%ssql%ssql%scFPrstTvfp',
\ 'tcl' : '%stcl%stcl%scfmp',
\ 'vera' : '%svera%svera%scdefgmpPtTvx',
\ 'verilog': '%sverilog%sverilog%smcPertwpvf',
\ 'vim' : '%svim%svim%savf',
\ 'yacc' : '%syacc%syacc%sl',
\ }
cal map(s:types, 'printf(v:val, "--language-force=", " --", "-types=")')
if executable('jsctags')
cal extend(s:types, { 'javascript': { 'args': '-f -', 'bin': 'jsctags' } })
en
fu! ctrlp#buffertag#opts()
for [ke, va] in items(s:opts)
let {va[0]} = exists(s:pref.ke) ? {s:pref.ke} : va[1]
endfo
" Ctags bin
if empty(s:bin)
for bin in s:bins | if executable(bin)
let s:bin = bin
brea
en | endfo
el
let s:bin = expand(s:bin, 1)
en
" Types
cal extend(s:types, s:usr_types)
endf
" Utilities {{{1
fu! s:validfile(fname, ftype)
if ( !empty(a:fname) || !empty(a:ftype) ) && filereadable(a:fname)
\ && index(keys(s:types), a:ftype) >= 0 | retu 1 | en
retu 0
endf
fu! s:exectags(cmd)
if exists('+ssl')
let [ssl, &ssl] = [&ssl, 0]
en
if &sh =~ 'cmd\.exe'
let [sxq, &sxq, shcf, &shcf] = [&sxq, '"', &shcf, '/s /c']
en
let output = system(a:cmd)
if &sh =~ 'cmd\.exe'
let [&sxq, &shcf] = [sxq, shcf]
en
if exists('+ssl')
let &ssl = ssl
en
retu output
endf
fu! s:exectagsonfile(fname, ftype)
let [ags, ft] = ['-f - --sort=no --excmd=pattern --fields=nKs ', a:ftype]
if type(s:types[ft]) == 1
let ags .= s:types[ft]
let bin = s:bin
elsei type(s:types[ft]) == 4
let ags = s:types[ft]['args']
let bin = expand(s:types[ft]['bin'], 1)
en
if empty(bin) | retu '' | en
let cmd = s:esctagscmd(bin, ags, a:fname)
if empty(cmd) | retu '' | en
let output = s:exectags(cmd)
if v:shell_error || output =~ 'Warning: cannot open' | retu '' | en
retu output
endf
fu! s:esctagscmd(bin, args, ...)
if exists('+ssl')
let [ssl, &ssl] = [&ssl, 0]
en
let fname = a:0 ? shellescape(a:1) : ''
let cmd = shellescape(a:bin).' '.a:args.' '.fname
if &sh =~ 'cmd\.exe'
let cmd = substitute(cmd, '[&()@^<>|]', '^\0', 'g')
en
if exists('+ssl')
let &ssl = ssl
en
if has('iconv')
let last = s:enc != &enc ? s:enc : !empty( $LANG ) ? $LANG : &enc
let cmd = iconv(cmd, &enc, last)
en
retu cmd
endf
fu! s:process(fname, ftype)
if !s:validfile(a:fname, a:ftype) | retu [] | endif
let ftime = getftime(a:fname)
if has_key(g:ctrlp_buftags, a:fname)
\ && g:ctrlp_buftags[a:fname]['time'] >= ftime
let lines = g:ctrlp_buftags[a:fname]['lines']
el
let data = s:exectagsonfile(a:fname, a:ftype)
let [raw, lines] = [split(data, '\n\+'), []]
for line in raw
if line !~# '^!_TAG_' && len(split(line, ';"')) == 2
let parsed_line = s:parseline(line)
if parsed_line != ''
cal add(lines, parsed_line)
en
en
endfo
let cache = { a:fname : { 'time': ftime, 'lines': lines } }
cal extend(g:ctrlp_buftags, cache)
en
retu lines
endf
fu! s:parseline(line)
let vals = matchlist(a:line,
\ '\v^([^\t]+)\t(.+)\t[?/]\^?(.{-1,})\$?[?/]\;\"\t(.+)\tline(no)?\:(\d+)')
if vals == [] | retu '' | en
let [bufnr, bufname] = [bufnr('^'.vals[2].'$'), fnamemodify(vals[2], ':p:t')]
retu vals[1].' '.vals[4].'|'.bufnr.':'.bufname.'|'.vals[6].'| '.vals[3]
endf
fu! s:syntax()
if !ctrlp#nosy()
cal ctrlp#hicheck('CtrlPTagKind', 'Title')
cal ctrlp#hicheck('CtrlPBufName', 'Directory')
cal ctrlp#hicheck('CtrlPTabExtra', 'Comment')
sy match CtrlPTagKind '\zs[^\t|]\+\ze|\d\+:[^|]\+|\d\+|'
sy match CtrlPBufName '|\d\+:\zs[^|]\+\ze|\d\+|'
sy match CtrlPTabExtra '\zs\t.*\ze$' contains=CtrlPBufName,CtrlPTagKind
en
endf
fu! s:chknearby(pat)
if match(getline('.'), a:pat) < 0
let [int, forw, maxl] = [1, 1, line('$')]
wh !search(a:pat, 'W'.( forw ? '' : 'b' ))
if !forw
if int > maxl | brea | en
let int += int
en
let forw = !forw
endw
en
endf
" Public {{{1
fu! ctrlp#buffertag#init(fname)
let bufs = exists('s:btmode') && s:btmode
\ ? filter(ctrlp#buffers(), 'filereadable(v:val)')
\ : [exists('s:bufname') ? s:bufname : a:fname]
let lines = []
for each in bufs
let bname = fnamemodify(each, ':p')
let tftype = get(split(getbufvar('^'.bname.'$', '&ft'), '\.'), 0, '')
cal extend(lines, s:process(bname, tftype))
endfo
cal s:syntax()
retu lines
endf
fu! ctrlp#buffertag#accept(mode, str)
let vals = matchlist(a:str,
\ '\v^[^\t]+\t+[^\t|]+\|(\d+)\:[^\t|]+\|(\d+)\|\s(.+)$')
let bufnr = str2nr(get(vals, 1))
if bufnr
cal ctrlp#acceptfile(a:mode, bufname(bufnr))
exe 'norm!' str2nr(get(vals, 2, line('.'))).'G'
cal s:chknearby('\V\C'.get(vals, 3, ''))
sil! norm! zvzz
en
endf
fu! ctrlp#buffertag#cmd(mode, ...)
let s:btmode = a:mode
if a:0 && !empty(a:1)
let s:bufname = fnamemodify(a:1, ':p')
en
retu s:id
endf
fu! ctrlp#buffertag#exit()
unl! s:btmode s:bufname
endf
"}}}
" vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2

@ -0,0 +1,95 @@
" =============================================================================
" File: autoload/ctrlp/changes.vim
" Description: Change list extension
" Author: Kien Nguyen <github.com/kien>
" =============================================================================
" Init {{{1
if exists('g:loaded_ctrlp_changes') && g:loaded_ctrlp_changes
fini
en
let g:loaded_ctrlp_changes = 1
cal add(g:ctrlp_ext_vars, {
\ 'init': 'ctrlp#changes#init(s:bufnr, s:crbufnr)',
\ 'accept': 'ctrlp#changes#accept',
\ 'lname': 'changes',
\ 'sname': 'chs',
\ 'exit': 'ctrlp#changes#exit()',
\ 'type': 'tabe',
\ 'sort': 0,
\ 'nolim': 1,
\ })
let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars)
" Utilities {{{1
fu! s:changelist(bufnr)
sil! exe 'noa hid b' a:bufnr
redi => result
sil! changes
redi END
retu map(split(result, "\n")[1:], 'tr(v:val, " ", " ")')
endf
fu! s:process(clines, ...)
let [clines, evas] = [[], []]
for each in a:clines
let parts = matchlist(each, '\v^.\s*\d+\s+(\d+)\s+(\d+)\s(.*)$')
if !empty(parts)
if parts[3] == '' | let parts[3] = ' ' | en
cal add(clines, parts[3].' |'.a:1.':'.a:2.'|'.parts[1].':'.parts[2].'|')
en
endfo
retu reverse(filter(clines, 'count(clines, v:val) == 1'))
endf
fu! s:syntax()
if !ctrlp#nosy()
cal ctrlp#hicheck('CtrlPBufName', 'Directory')
cal ctrlp#hicheck('CtrlPTabExtra', 'Comment')
sy match CtrlPBufName '\t|\d\+:\zs[^|]\+\ze|\d\+:\d\+|$'
sy match CtrlPTabExtra '\zs\t.*\ze$' contains=CtrlPBufName
en
endf
" Public {{{1
fu! ctrlp#changes#init(original_bufnr, bufnr)
let bufnr = exists('s:bufnr') ? s:bufnr : a:bufnr
let bufs = exists('s:clmode') && s:clmode ? ctrlp#buffers('id') : [bufnr]
cal filter(bufs, 'v:val > 0')
let [swb, &swb] = [&swb, '']
let lines = []
for each in bufs
let fnamet = fnamemodify(bufname(each), ':t')
cal extend(lines, s:process(s:changelist(each), each, fnamet))
endfo
sil! exe 'noa hid b' a:original_bufnr
let &swb = swb
cal ctrlp#syntax()
cal s:syntax()
retu lines
endf
fu! ctrlp#changes#accept(mode, str)
let info = matchlist(a:str, '\t|\(\d\+\):[^|]\+|\(\d\+\):\(\d\+\)|$')
let bufnr = str2nr(get(info, 1))
if bufnr
cal ctrlp#acceptfile(a:mode, bufname(bufnr))
cal cursor(get(info, 2), get(info, 3))
sil! norm! zvzz
en
endf
fu! ctrlp#changes#cmd(mode, ...)
let s:clmode = a:mode
if a:0 && !empty(a:1)
let s:bufnr = bufnr('^'.fnamemodify(a:1, ':p').'$')
en
retu s:id
endf
fu! ctrlp#changes#exit()
unl! s:clmode s:bufnr
endf
"}}}
" vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2

@ -0,0 +1,93 @@
" =============================================================================
" File: autoload/ctrlp/dir.vim
" Description: Directory extension
" Author: Kien Nguyen <github.com/kien>
" =============================================================================
" Init {{{1
if exists('g:loaded_ctrlp_dir') && g:loaded_ctrlp_dir
fini
en
let [g:loaded_ctrlp_dir, g:ctrlp_newdir] = [1, 0]
let s:ars = ['s:maxdepth', 's:maxfiles', 's:compare_lim', 's:glob', 's:caching']
cal add(g:ctrlp_ext_vars, {
\ 'init': 'ctrlp#dir#init('.join(s:ars, ', ').')',
\ 'accept': 'ctrlp#dir#accept',
\ 'lname': 'dirs',
\ 'sname': 'dir',
\ 'type': 'path',
\ 'specinput': 1,
\ })
let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars)
let s:dircounts = {}
" Utilities {{{1
fu! s:globdirs(dirs, depth)
let entries = split(globpath(a:dirs, s:glob), "\n")
let [dirs, depth] = [ctrlp#dirnfile(entries)[0], a:depth + 1]
cal extend(g:ctrlp_alldirs, dirs)
let nr = len(g:ctrlp_alldirs)
if !empty(dirs) && !s:max(nr, s:maxfiles) && depth <= s:maxdepth
sil! cal ctrlp#progress(nr)
cal map(dirs, 'ctrlp#utils#fnesc(v:val, "g", ",")')
cal s:globdirs(join(dirs, ','), depth)
en
endf
fu! s:max(len, max)
retu a:max && a:len > a:max
endf
fu! s:nocache()
retu !s:caching || ( s:caching > 1 && get(s:dircounts, s:cwd) < s:caching )
endf
" Public {{{1
fu! ctrlp#dir#init(...)
let s:cwd = getcwd()
for each in range(len(s:ars))
let {s:ars[each]} = a:{each + 1}
endfo
let cadir = ctrlp#utils#cachedir().ctrlp#utils#lash().'dir'
let cafile = cadir.ctrlp#utils#lash().ctrlp#utils#cachefile('dir')
if g:ctrlp_newdir || s:nocache() || !filereadable(cafile)
let [s:initcwd, g:ctrlp_alldirs] = [s:cwd, []]
cal s:globdirs(ctrlp#utils#fnesc(s:cwd, 'g', ','), 0)
cal ctrlp#rmbasedir(g:ctrlp_alldirs)
if len(g:ctrlp_alldirs) <= s:compare_lim
cal sort(g:ctrlp_alldirs, 'ctrlp#complen')
en
cal ctrlp#utils#writecache(g:ctrlp_alldirs, cadir, cafile)
let g:ctrlp_newdir = 0
el
if !( exists('s:initcwd') && s:initcwd == s:cwd )
let s:initcwd = s:cwd
let g:ctrlp_alldirs = ctrlp#utils#readfile(cafile)
en
en
cal extend(s:dircounts, { s:cwd : len(g:ctrlp_alldirs) })
retu g:ctrlp_alldirs
endf
fu! ctrlp#dir#accept(mode, str)
let path = a:mode == 'h' ? getcwd() : s:cwd.ctrlp#utils#lash().a:str
if a:mode =~ 't\|v\|h'
cal ctrlp#exit()
en
cal ctrlp#setdir(path, a:mode =~ 't\|h' ? 'chd!' : 'lc!')
if a:mode == 'e'
sil! cal ctrlp#statusline()
cal ctrlp#setlines(s:id)
cal ctrlp#recordhist()
cal ctrlp#prtclear()
en
endf
fu! ctrlp#dir#id()
retu s:id
endf
"}}}
" vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2

@ -0,0 +1,62 @@
" =============================================================================
" File: autoload/ctrlp/line.vim
" Description: Line extension
" Author: Kien Nguyen <github.com/kien>
" =============================================================================
" Init {{{1
if exists('g:loaded_ctrlp_line') && g:loaded_ctrlp_line
fini
en
let g:loaded_ctrlp_line = 1
cal add(g:ctrlp_ext_vars, {
\ 'init': 'ctrlp#line#init()',
\ 'accept': 'ctrlp#line#accept',
\ 'lname': 'lines',
\ 'sname': 'lns',
\ 'type': 'tabe',
\ })
let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars)
" Utilities {{{1
fu! s:syntax()
if !ctrlp#nosy()
cal ctrlp#hicheck('CtrlPBufName', 'Directory')
cal ctrlp#hicheck('CtrlPTabExtra', 'Comment')
sy match CtrlPBufName '\t|\zs[^|]\+\ze|\d\+:\d\+|$'
sy match CtrlPTabExtra '\zs\t.*\ze$' contains=CtrlPBufName
en
endf
" Public {{{1
fu! ctrlp#line#init()
let [bufs, lines] = [ctrlp#buffers('id'), []]
for bufnr in bufs
let [lfb, bufn] = [getbufline(bufnr, 1, '$'), bufname(bufnr)]
let lfb = lfb == [] ? ctrlp#utils#readfile(fnamemodify(bufn, ':p')) : lfb
cal map(lfb, 'tr(v:val, '' '', '' '')')
let [linenr, len_lfb, buft] = [1, len(lfb), fnamemodify(bufn, ':t')]
wh linenr <= len_lfb
let lfb[linenr - 1] .= ' |'.buft.'|'.bufnr.':'.linenr.'|'
let linenr += 1
endw
cal extend(lines, filter(lfb, 'v:val !~ ''^\s*\t|[^|]\+|\d\+:\d\+|$'''))
endfo
cal s:syntax()
retu lines
endf
fu! ctrlp#line#accept(mode, str)
let info = matchlist(a:str, '\t|[^|]\+|\(\d\+\):\(\d\+\)|$')
let bufnr = str2nr(get(info, 1))
if bufnr
cal ctrlp#acceptfile(a:mode, bufname(bufnr), get(info, 2))
en
endf
fu! ctrlp#line#id()
retu s:id
endf
"}}}
" vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2

@ -0,0 +1,83 @@
" =============================================================================
" File: autoload/ctrlp/mixed.vim
" Description: Mixing Files + MRU + Buffers
" Author: Kien Nguyen <github.com/kien>
" =============================================================================
" Init {{{1
if exists('g:loaded_ctrlp_mixed') && g:loaded_ctrlp_mixed
fini
en
let [g:loaded_ctrlp_mixed, g:ctrlp_newmix] = [1, 0]
cal add(g:ctrlp_ext_vars, {
\ 'init': 'ctrlp#mixed#init(s:compare_lim)',
\ 'accept': 'ctrlp#acceptfile',
\ 'lname': 'fil + mru + buf',
\ 'sname': 'mix',
\ 'type': 'path',
\ 'opmul': 1,
\ 'specinput': 1,
\ })
let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars)
" Utilities {{{1
fu! s:newcache(cwd)
if g:ctrlp_newmix || !has_key(g:ctrlp_allmixes, 'data') | retu 1 | en
retu g:ctrlp_allmixes['cwd'] != a:cwd
\ || g:ctrlp_allmixes['filtime'] < getftime(ctrlp#utils#cachefile())
\ || g:ctrlp_allmixes['mrutime'] < getftime(ctrlp#mrufiles#cachefile())
\ || g:ctrlp_allmixes['bufs'] < len(ctrlp#mrufiles#bufs())
endf
fu! s:getnewmix(cwd, clim)
if g:ctrlp_newmix
cal ctrlp#mrufiles#refresh('raw')
let g:ctrlp_newcache = 1
en
let g:ctrlp_lines = copy(ctrlp#files())
cal ctrlp#progress('Mixing...')
let mrufs = copy(ctrlp#mrufiles#list('raw'))
if exists('+ssl') && &ssl
cal map(mrufs, 'tr(v:val, "\\", "/")')
en
let bufs = map(ctrlp#buffers('id'), 'fnamemodify(bufname(v:val), ":p")')
let mrufs = bufs + filter(mrufs, 'index(bufs, v:val) < 0')
if len(mrufs) > len(g:ctrlp_lines)
cal filter(mrufs, 'stridx(v:val, a:cwd)')
el
let cwd_mrufs = filter(copy(mrufs), '!stridx(v:val, a:cwd)')
let cwd_mrufs = ctrlp#rmbasedir(cwd_mrufs)
for each in cwd_mrufs
let id = index(g:ctrlp_lines, each)
if id >= 0 | cal remove(g:ctrlp_lines, id) | en
endfo
en
cal map(mrufs, 'fnamemodify(v:val, ":.")')
let g:ctrlp_lines = len(mrufs) > len(g:ctrlp_lines)
\ ? g:ctrlp_lines + mrufs : mrufs + g:ctrlp_lines
if len(g:ctrlp_lines) <= a:clim
cal sort(g:ctrlp_lines, 'ctrlp#complen')
en
let g:ctrlp_allmixes = { 'filtime': getftime(ctrlp#utils#cachefile()),
\ 'mrutime': getftime(ctrlp#mrufiles#cachefile()), 'cwd': a:cwd,
\ 'bufs': len(ctrlp#mrufiles#bufs()), 'data': g:ctrlp_lines }
endf
" Public {{{1
fu! ctrlp#mixed#init(clim)
let cwd = getcwd()
if s:newcache(cwd)
cal s:getnewmix(cwd, a:clim)
el
let g:ctrlp_lines = g:ctrlp_allmixes['data']
en
let g:ctrlp_newmix = 0
retu g:ctrlp_lines
endf
fu! ctrlp#mixed#id()
retu s:id
endf
"}}}
" vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2

@ -0,0 +1,148 @@
" =============================================================================
" File: autoload/ctrlp/mrufiles.vim
" Description: Most Recently Used Files extension
" Author: Kien Nguyen <github.com/kien>
" =============================================================================
" Static variables {{{1
let [s:mrbs, s:mrufs] = [[], []]
fu! ctrlp#mrufiles#opts()
let [pref, opts] = ['g:ctrlp_mruf_', {
\ 'max': ['s:max', 250],
\ 'include': ['s:in', ''],
\ 'exclude': ['s:ex', ''],
\ 'case_sensitive': ['s:cseno', 1],
\ 'relative': ['s:re', 0],
\ 'save_on_update': ['s:soup', 1],
\ }]
for [ke, va] in items(opts)
let [{va[0]}, {pref.ke}] = [pref.ke, exists(pref.ke) ? {pref.ke} : va[1]]
endfo
endf
cal ctrlp#mrufiles#opts()
" Utilities {{{1
fu! s:excl(fn)
retu !empty({s:ex}) && a:fn =~# {s:ex}
endf
fu! s:mergelists()
let diskmrufs = ctrlp#utils#readfile(ctrlp#mrufiles#cachefile())
cal filter(diskmrufs, 'index(s:mrufs, v:val) < 0')
let mrufs = s:mrufs + diskmrufs
retu s:chop(mrufs)
endf
fu! s:chop(mrufs)
if len(a:mrufs) > {s:max} | cal remove(a:mrufs, {s:max}, -1) | en
retu a:mrufs
endf
fu! s:reformat(mrufs)
let cwd = getcwd()
let cwd .= cwd !~ '[\/]$' ? ctrlp#utils#lash() : ''
if {s:re}
let cwd = exists('+ssl') ? tr(cwd, '/', '\') : cwd
cal filter(a:mrufs, '!stridx(v:val, cwd)')
en
let idx = strlen(cwd)
if exists('+ssl') && &ssl
let cwd = tr(cwd, '\', '/')
cal map(a:mrufs, 'tr(v:val, "\\", "/")')
en
retu map(a:mrufs, '!stridx(v:val, cwd) ? strpart(v:val, idx) : v:val')
endf
fu! s:record(bufnr)
if s:locked | retu | en
let bufnr = a:bufnr + 0
let bufname = bufname(bufnr)
if bufnr > 0 && !empty(bufname)
cal filter(s:mrbs, 'v:val != bufnr')
cal insert(s:mrbs, bufnr)
cal s:addtomrufs(bufname)
en
endf
fu! s:addtomrufs(fname)
let fn = fnamemodify(a:fname, ':p')
let fn = exists('+ssl') ? tr(fn, '/', '\') : fn
if ( !empty({s:in}) && fn !~# {s:in} ) || ( !empty({s:ex}) && fn =~# {s:ex} )
\ || !empty(getbufvar('^'.fn.'$', '&bt')) || !filereadable(fn) | retu
en
let idx = index(s:mrufs, fn, 0, !{s:cseno})
if idx
cal filter(s:mrufs, 'v:val !='.( {s:cseno} ? '#' : '?' ).' fn')
cal insert(s:mrufs, fn)
if {s:soup} && idx < 0
cal s:savetofile(s:mergelists())
en
en
endf
fu! s:savetofile(mrufs)
cal ctrlp#utils#writecache(a:mrufs, s:cadir, s:cafile)
endf
" Public {{{1
fu! ctrlp#mrufiles#refresh(...)
let mrufs = s:mergelists()
cal filter(mrufs, '!empty(ctrlp#utils#glob(v:val, 1)) && !s:excl(v:val)')
if exists('+ssl')
cal map(mrufs, 'tr(v:val, "/", "\\")')
cal map(s:mrufs, 'tr(v:val, "/", "\\")')
let cond = 'count(mrufs, v:val, !{s:cseno}) == 1'
cal filter(mrufs, cond)
cal filter(s:mrufs, cond)
en
cal s:savetofile(mrufs)
retu a:0 && a:1 == 'raw' ? [] : s:reformat(mrufs)
endf
fu! ctrlp#mrufiles#remove(files)
let mrufs = []
if a:files != []
let mrufs = s:mergelists()
let cond = 'index(a:files, v:val, 0, !{s:cseno}) < 0'
cal filter(mrufs, cond)
cal filter(s:mrufs, cond)
en
cal s:savetofile(mrufs)
retu s:reformat(mrufs)
endf
fu! ctrlp#mrufiles#add(fn)
if !empty(a:fn)
cal s:addtomrufs(a:fn)
en
endf
fu! ctrlp#mrufiles#list(...)
retu a:0 ? a:1 == 'raw' ? s:mergelists() : 0 : s:reformat(s:mergelists())
endf
fu! ctrlp#mrufiles#bufs()
retu s:mrbs
endf
fu! ctrlp#mrufiles#cachefile()
if !exists('s:cadir') || !exists('s:cafile')
let s:cadir = ctrlp#utils#cachedir().ctrlp#utils#lash().'mru'
let s:cafile = s:cadir.ctrlp#utils#lash().'cache.txt'
en
retu s:cafile
endf
fu! ctrlp#mrufiles#init()
if !has('autocmd') | retu | en
let s:locked = 0
aug CtrlPMRUF
au!
au BufAdd,BufEnter,BufLeave,BufWritePost * cal s:record(expand('<abuf>', 1))
au QuickFixCmdPre *vimgrep* let s:locked = 1
au QuickFixCmdPost *vimgrep* let s:locked = 0
au VimLeavePre * cal s:savetofile(s:mergelists())
aug END
endf
"}}}
" vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2

@ -0,0 +1,59 @@
" =============================================================================
" File: autoload/ctrlp/quickfix.vim
" Description: Quickfix extension
" Author: Kien Nguyen <github.com/kien>
" =============================================================================
" Init {{{1
if exists('g:loaded_ctrlp_quickfix') && g:loaded_ctrlp_quickfix
fini
en
let g:loaded_ctrlp_quickfix = 1
cal add(g:ctrlp_ext_vars, {
\ 'init': 'ctrlp#quickfix#init()',
\ 'accept': 'ctrlp#quickfix#accept',
\ 'lname': 'quickfix',
\ 'sname': 'qfx',
\ 'type': 'line',
\ 'sort': 0,
\ 'nolim': 1,
\ })
let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars)
fu! s:lineout(dict)
retu printf('%s|%d:%d| %s', bufname(a:dict['bufnr']), a:dict['lnum'],
\ a:dict['col'], matchstr(a:dict['text'], '\s*\zs.*\S'))
endf
" Utilities {{{1
fu! s:syntax()
if !ctrlp#nosy()
cal ctrlp#hicheck('CtrlPqfLineCol', 'Search')
sy match CtrlPqfLineCol '|\zs\d\+:\d\+\ze|'
en
endf
" Public {{{1
fu! ctrlp#quickfix#init()
cal s:syntax()
retu map(getqflist(), 's:lineout(v:val)')
endf
fu! ctrlp#quickfix#accept(mode, str)
let vals = matchlist(a:str, '^\([^|]\+\ze\)|\(\d\+\):\(\d\+\)|')
if vals == [] || vals[1] == '' | retu | en
cal ctrlp#acceptfile(a:mode, vals[1])
let cur_pos = getpos('.')[1:2]
if cur_pos != [1, 1] && cur_pos != map(vals[2:3], 'str2nr(v:val)')
mark '
en
cal cursor(vals[2], vals[3])
sil! norm! zvzz
endf
fu! ctrlp#quickfix#id()
retu s:id
endf
"}}}
" vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2

@ -0,0 +1,59 @@
" =============================================================================
" File: autoload/ctrlp/rtscript.vim
" Description: Runtime scripts extension
" Author: Kien Nguyen <github.com/kien>
" =============================================================================
" Init {{{1
if exists('g:loaded_ctrlp_rtscript') && g:loaded_ctrlp_rtscript
fini
en
let [g:loaded_ctrlp_rtscript, g:ctrlp_newrts] = [1, 0]
cal add(g:ctrlp_ext_vars, {
\ 'init': 'ctrlp#rtscript#init(s:caching)',
\ 'accept': 'ctrlp#acceptfile',
\ 'lname': 'runtime scripts',
\ 'sname': 'rts',
\ 'type': 'path',
\ 'opmul': 1,
\ })
let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars)
let s:filecounts = {}
" Utilities {{{1
fu! s:nocache()
retu g:ctrlp_newrts ||
\ !s:caching || ( s:caching > 1 && get(s:filecounts, s:cwd) < s:caching )
endf
" Public {{{1
fu! ctrlp#rtscript#init(caching)
let [s:caching, s:cwd] = [a:caching, getcwd()]
if s:nocache() ||
\ !( exists('g:ctrlp_rtscache') && g:ctrlp_rtscache[0] == &rtp )
sil! cal ctrlp#progress('Indexing...')
let entries = split(globpath(ctrlp#utils#fnesc(&rtp, 'g'), '**/*.*'), "\n")
cal filter(entries, 'count(entries, v:val) == 1')
let [entries, echoed] = [ctrlp#dirnfile(entries)[1], 1]
el
let [entries, results] = g:ctrlp_rtscache[2:3]
en
if s:nocache() ||
\ !( exists('g:ctrlp_rtscache') && g:ctrlp_rtscache[:1] == [&rtp, s:cwd] )
if !exists('echoed')
sil! cal ctrlp#progress('Processing...')
en
let results = map(copy(entries), 'fnamemodify(v:val, '':.'')')
en
let [g:ctrlp_rtscache, g:ctrlp_newrts] = [[&rtp, s:cwd, entries, results], 0]
cal extend(s:filecounts, { s:cwd : len(results) })
retu results
endf
fu! ctrlp#rtscript#id()
retu s:id
endf
"}}}
" vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2

@ -0,0 +1,128 @@
" =============================================================================
" File: autoload/ctrlp/tag.vim
" Description: Tag file extension
" Author: Kien Nguyen <github.com/kien>
" =============================================================================
" Init {{{1
if exists('g:loaded_ctrlp_tag') && g:loaded_ctrlp_tag
fini
en
let g:loaded_ctrlp_tag = 1
cal add(g:ctrlp_ext_vars, {
\ 'init': 'ctrlp#tag#init()',
\ 'accept': 'ctrlp#tag#accept',
\ 'lname': 'tags',
\ 'sname': 'tag',
\ 'enter': 'ctrlp#tag#enter()',
\ 'type': 'tabs',
\ })
let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars)
" Utilities {{{1
fu! s:findcount(str)
let [tg, fname] = split(a:str, '\t\+\ze[^\t]\+$')
let tgs = taglist('^'.tg.'$')
if len(tgs) < 2
retu [1, 1]
en
let bname = fnamemodify(bufname('%'), ':p')
let fname = expand(fnamemodify(simplify(fname), ':s?^[.\/]\+??:p:.'), 1)
let [fnd, ct, pos, idx] = [0, 0, 0, 0]
wh idx < len(tgs)
if bname == fnamemodify(tgs[idx]["filename"], ':p')
cal insert(tgs, remove(tgs, idx))
brea
en
let idx += 1
endw
for each in tgs
let ct += 1
let fulname = fnamemodify(each["filename"], ':p')
if stridx(fulname, fname) >= 0
\ && strlen(fname) + stridx(fulname, fname) == strlen(fulname)
let fnd += 1
let pos = ct
en
if fnd > 1 | brea | en
endfo
retu [fnd, pos]
endf
fu! s:filter(tags)
let nr = 0
wh 0 < 1
if a:tags == [] | brea | en
if a:tags[nr] =~ '^!' && a:tags[nr] !~# '^!_TAG_'
let nr += 1
con
en
if a:tags[nr] =~# '^!_TAG_' && len(a:tags) > nr
cal remove(a:tags, nr)
el
brea
en
endw
retu a:tags
endf
fu! s:syntax()
if !ctrlp#nosy()
cal ctrlp#hicheck('CtrlPTabExtra', 'Comment')
sy match CtrlPTabExtra '\zs\t.*\ze$'
en
endf
" Public {{{1
fu! ctrlp#tag#init()
if empty(s:tagfiles) | retu [] | en
let g:ctrlp_alltags = []
let tagfiles = sort(filter(s:tagfiles, 'count(s:tagfiles, v:val) == 1'))
for each in tagfiles
let alltags = s:filter(ctrlp#utils#readfile(each))
cal extend(g:ctrlp_alltags, alltags)
endfo
cal s:syntax()
retu g:ctrlp_alltags
endf
fu! ctrlp#tag#accept(mode, str)
cal ctrlp#exit()
let str = matchstr(a:str, '^[^\t]\+\t\+[^\t]\+\ze\t')
let [tg, fnd] = [split(str, '^[^\t]\+\zs\t')[0], s:findcount(str)]
let cmds = {
\ 't': ['tab sp', 'tab stj'],
\ 'h': ['sp', 'stj'],
\ 'v': ['vs', 'vert stj'],
\ 'e': ['', 'tj'],
\ }
let cmd = fnd[0] == 1 ? cmds[a:mode][0] : cmds[a:mode][1]
let cmd = a:mode == 'e' && ctrlp#modfilecond(!&aw)
\ ? ( cmd == 'tj' ? 'stj' : 'sp' ) : cmd
let cmd = a:mode == 't' ? ctrlp#tabcount().cmd : cmd
if fnd[0] == 1
if cmd != ''
exe cmd
en
let save_cst = &cst
set cst&
cal feedkeys(":".fnd[1]."ta ".tg."\r", 'nt')
let &cst = save_cst
el
cal feedkeys(":".cmd." ".tg."\r", 'nt')
en
cal ctrlp#setlcdir()
endf
fu! ctrlp#tag#id()
retu s:id
endf
fu! ctrlp#tag#enter()
let tfs = tagfiles()
let s:tagfiles = tfs != [] ? filter(map(tfs, 'fnamemodify(v:val, ":p")'),
\ 'filereadable(v:val)') : []
endf
"}}}
" vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2

@ -0,0 +1,154 @@
" =============================================================================
" File: autoload/ctrlp/undo.vim
" Description: Undo extension
" Author: Kien Nguyen <github.com/kien>
" =============================================================================
" Init {{{1
if ( exists('g:loaded_ctrlp_undo') && g:loaded_ctrlp_undo )
fini
en
let g:loaded_ctrlp_undo = 1
cal add(g:ctrlp_ext_vars, {
\ 'init': 'ctrlp#undo#init()',
\ 'accept': 'ctrlp#undo#accept',
\ 'lname': 'undo',
\ 'sname': 'udo',
\ 'enter': 'ctrlp#undo#enter()',
\ 'exit': 'ctrlp#undo#exit()',
\ 'type': 'line',
\ 'sort': 0,
\ 'nolim': 1,
\ })
let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars)
let s:text = map(['second', 'seconds', 'minutes', 'hours', 'days', 'weeks',
\ 'months', 'years'], '" ".v:val." ago"')
" Utilities {{{1
fu! s:getundo()
if exists('*undotree')
\ && ( v:version > 703 || ( v:version == 703 && has('patch005') ) )
retu [1, undotree()]
el
redi => result
sil! undol
redi END
retu [0, split(result, "\n")[1:]]
en
endf
fu! s:flatten(tree, cur)
let flatdict = {}
for each in a:tree
let saved = has_key(each, 'save') ? 'saved' : ''
let current = each['seq'] == a:cur ? 'current' : ''
cal extend(flatdict, { each['seq'] : [each['time'], saved, current] })
if has_key(each, 'alt')
cal extend(flatdict, s:flatten(each['alt'], a:cur))
en
endfo
retu flatdict
endf
fu! s:elapsed(nr)
let [text, time] = [s:text, localtime() - a:nr]
let mins = time / 60
let hrs = time / 3600
let days = time / 86400
let wks = time / 604800
let mons = time / 2592000
let yrs = time / 31536000
if yrs > 1
retu yrs.text[7]
elsei mons > 1
retu mons.text[6]
elsei wks > 1
retu wks.text[5]
elsei days > 1
retu days.text[4]
elsei hrs > 1
retu hrs.text[3]
elsei mins > 1
retu mins.text[2]
elsei time == 1
retu time.text[0]
elsei time < 120
retu time.text[1]
en
endf
fu! s:syntax()
if ctrlp#nosy() | retu | en
for [ke, va] in items({'T': 'Directory', 'Br': 'Comment', 'Nr': 'String',
\ 'Sv': 'Comment', 'Po': 'Title'})
cal ctrlp#hicheck('CtrlPUndo'.ke, va)
endfo
sy match CtrlPUndoT '\v\d+ \zs[^ ]+\ze|\d+:\d+:\d+'
sy match CtrlPUndoBr '\[\|\]'
sy match CtrlPUndoNr '\[\d\+\]' contains=CtrlPUndoBr
sy match CtrlPUndoSv 'saved'
sy match CtrlPUndoPo 'current'
endf
fu! s:dict2list(dict)
for ke in keys(a:dict)
let a:dict[ke][0] = s:elapsed(a:dict[ke][0])
endfo
retu map(keys(a:dict), 'eval(''[v:val, a:dict[v:val]]'')')
endf
fu! s:compval(...)
retu a:2[0] - a:1[0]
endf
fu! s:format(...)
let saved = !empty(a:1[1][1]) ? ' '.a:1[1][1] : ''
let current = !empty(a:1[1][2]) ? ' '.a:1[1][2] : ''
retu a:1[1][0].' ['.a:1[0].']'.saved.current
endf
fu! s:formatul(...)
let parts = matchlist(a:1,
\ '\v^\s+(\d+)\s+\d+\s+([^ ]+\s?[^ ]+|\d+\s\w+\s\w+)(\s*\d*)$')
retu parts == [] ? '----'
\ : parts[2].' ['.parts[1].']'.( parts[3] != '' ? ' saved' : '' )
endf
" Public {{{1
fu! ctrlp#undo#init()
let entries = s:undos[0] ? s:undos[1]['entries'] : s:undos[1]
if empty(entries) | retu [] | en
if !exists('s:lines')
if s:undos[0]
let entries = s:dict2list(s:flatten(entries, s:undos[1]['seq_cur']))
let s:lines = map(sort(entries, 's:compval'), 's:format(v:val)')
el
let s:lines = map(reverse(entries), 's:formatul(v:val)')
en
en
cal s:syntax()
retu s:lines
endf
fu! ctrlp#undo#accept(mode, str)
let undon = matchstr(a:str, '\[\zs\d\+\ze\]')
if empty(undon) | retu | en
cal ctrlp#exit()
exe 'u' undon
endf
fu! ctrlp#undo#id()
retu s:id
endf
fu! ctrlp#undo#enter()
let s:undos = s:getundo()
endf
fu! ctrlp#undo#exit()
unl! s:lines
endf
"}}}
" vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2

@ -0,0 +1,120 @@
" =============================================================================
" File: autoload/ctrlp/utils.vim
" Description: Utilities
" Author: Kien Nguyen <github.com/kien>
" =============================================================================
" Static variables {{{1
fu! ctrlp#utils#lash()
retu &ssl || !exists('+ssl') ? '/' : '\'
endf
fu! s:lash(...)
retu ( a:0 ? a:1 : getcwd() ) !~ '[\/]$' ? s:lash : ''
endf
fu! ctrlp#utils#opts()
let s:lash = ctrlp#utils#lash()
let usrhome = $HOME . s:lash( $HOME )
let cahome = exists('$XDG_CACHE_HOME') ? $XDG_CACHE_HOME : usrhome.'.cache'
let cadir = isdirectory(usrhome.'.ctrlp_cache')
\ ? usrhome.'.ctrlp_cache' : cahome.s:lash(cahome).'ctrlp'
if exists('g:ctrlp_cache_dir')
let cadir = expand(g:ctrlp_cache_dir, 1)
if isdirectory(cadir.s:lash(cadir).'.ctrlp_cache')
let cadir = cadir.s:lash(cadir).'.ctrlp_cache'
en
en
let s:cache_dir = cadir
endf
cal ctrlp#utils#opts()
let s:wig_cond = v:version > 702 || ( v:version == 702 && has('patch051') )
" Files and Directories {{{1
fu! ctrlp#utils#cachedir()
retu s:cache_dir
endf
fu! ctrlp#utils#cachefile(...)
let [tail, dir] = [a:0 == 1 ? '.'.a:1 : '', a:0 == 2 ? a:1 : getcwd()]
let cache_file = substitute(dir, '\([\/]\|^\a\zs:\)', '%', 'g').tail.'.txt'
retu a:0 == 1 ? cache_file : s:cache_dir.s:lash(s:cache_dir).cache_file
endf
fu! ctrlp#utils#readfile(file)
if filereadable(a:file)
let data = readfile(a:file)
if empty(data) || type(data) != 3
unl data
let data = []
en
retu data
en
retu []
endf
fu! ctrlp#utils#mkdir(dir)
if exists('*mkdir') && !isdirectory(a:dir)
sil! cal mkdir(a:dir, 'p')
en
retu a:dir
endf
fu! ctrlp#utils#writecache(lines, ...)
if isdirectory(ctrlp#utils#mkdir(a:0 ? a:1 : s:cache_dir))
sil! cal writefile(a:lines, a:0 >= 2 ? a:2 : ctrlp#utils#cachefile())
en
endf
fu! ctrlp#utils#glob(...)
let path = ctrlp#utils#fnesc(a:1, 'g')
retu s:wig_cond ? glob(path, a:2) : glob(path)
endf
fu! ctrlp#utils#globpath(...)
retu call('globpath', s:wig_cond ? a:000 : a:000[:1])
endf
fu! ctrlp#utils#fnesc(path, type, ...)
if exists('*fnameescape')
if exists('+ssl')
if a:type == 'c'
let path = escape(a:path, '%#')
elsei a:type == 'f'
let path = fnameescape(a:path)
elsei a:type == 'g'
let path = escape(a:path, '?*')
en
let path = substitute(path, '[', '[[]', 'g')
el
let path = fnameescape(a:path)
en
el
if exists('+ssl')
if a:type == 'c'
let path = escape(a:path, '%#')
elsei a:type == 'f'
let path = escape(a:path, " \t\n%#*?|<\"")
elsei a:type == 'g'
let path = escape(a:path, '?*')
en
let path = substitute(path, '[', '[[]', 'g')
el
let path = escape(a:path, " \t\n*?[{`$\\%#'\"|!<")
en
en
retu a:0 ? escape(path, a:1) : path
endf
fu! ctrlp#utils#dircompl(...)
let [hsl, str] = [match(a:1, '[\/]'), '']
let par = substitute(a:1, '[^\/]*$', '', '')
let path = !hsl ? par : hsl > 0 ? getcwd().s:lash().par : getcwd()
for dir in split(globpath(ctrlp#utils#fnesc(path, 'g', ','), '*/'), '\n')
let str .= par.split(dir, '[\/]')[-1]."\n"
endfo
retu str
endf
"}}}
" vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2

File diff suppressed because it is too large Load Diff

@ -0,0 +1,69 @@
" =============================================================================
" File: plugin/ctrlp.vim
" Description: Fuzzy file, buffer, mru, tag, etc finder.
" Author: Kien Nguyen <github.com/kien>
" =============================================================================
" GetLatestVimScripts: 3736 1 :AutoInstall: ctrlp.zip
if ( exists('g:loaded_ctrlp') && g:loaded_ctrlp ) || v:version < 700 || &cp
fini
en
let g:loaded_ctrlp = 1
let [g:ctrlp_lines, g:ctrlp_allfiles, g:ctrlp_alltags, g:ctrlp_alldirs,
\ g:ctrlp_allmixes, g:ctrlp_buftags, g:ctrlp_ext_vars, g:ctrlp_builtins]
\ = [[], [], [], [], {}, {}, [], 2]
if !exists('g:ctrlp_map') | let g:ctrlp_map = '<c-p>' | en
if !exists('g:ctrlp_cmd') | let g:ctrlp_cmd = 'CtrlP' | en
com! -n=? -com=custom,ctrlp#utils#dircompl CtrlP
\ cal ctrlp#init(0, { 'dir': <q-args> })
com! -n=? -com=custom,ctrlp#utils#dircompl CtrlPMRUFiles
\ cal ctrlp#init(2, { 'dir': <q-args> })
com! -bar CtrlPBuffer cal ctrlp#init(1)
com! -n=? CtrlPLastMode cal ctrlp#init(-1, { 'args': <q-args> })
com! -bar CtrlPClearCache cal ctrlp#clr()
com! -bar CtrlPClearAllCaches cal ctrlp#clra()
com! -bar ClearCtrlPCache cal ctrlp#clr()
com! -bar ClearAllCtrlPCaches cal ctrlp#clra()
com! -bar CtrlPCurWD cal ctrlp#init(0, { 'mode': '' })
com! -bar CtrlPCurFile cal ctrlp#init(0, { 'mode': 'c' })
com! -bar CtrlPRoot cal ctrlp#init(0, { 'mode': 'r' })
if g:ctrlp_map != '' && !hasmapto(':<c-u>'.g:ctrlp_cmd.'<cr>', 'n')
exe 'nn <silent>' g:ctrlp_map ':<c-u>'.g:ctrlp_cmd.'<cr>'
en
cal ctrlp#mrufiles#init()
com! -bar CtrlPTag cal ctrlp#init(ctrlp#tag#id())
com! -bar CtrlPQuickfix cal ctrlp#init(ctrlp#quickfix#id())
com! -n=? -com=custom,ctrlp#utils#dircompl CtrlPDir
\ cal ctrlp#init(ctrlp#dir#id(), { 'dir': <q-args> })
com! -n=? -com=buffer CtrlPBufTag
\ cal ctrlp#init(ctrlp#buffertag#cmd(0, <q-args>))
com! -bar CtrlPBufTagAll cal ctrlp#init(ctrlp#buffertag#cmd(1))
com! -bar CtrlPRTS cal ctrlp#init(ctrlp#rtscript#id())
com! -bar CtrlPUndo cal ctrlp#init(ctrlp#undo#id())
com! -bar CtrlPLine cal ctrlp#init(ctrlp#line#id())
com! -n=? -com=buffer CtrlPChange
\ cal ctrlp#init(ctrlp#changes#cmd(0, <q-args>))
com! -bar CtrlPChangeAll cal ctrlp#init(ctrlp#changes#cmd(1))
com! -bar CtrlPMixed cal ctrlp#init(ctrlp#mixed#id())
com! -bar CtrlPBookmarkDir cal ctrlp#init(ctrlp#bookmarkdir#id())
com! -n=? -com=custom,ctrlp#utils#dircompl CtrlPBookmarkDirAdd
\ cal ctrlp#call('ctrlp#bookmarkdir#add', <q-args>)
" vim:ts=2:sw=2:sts=2

@ -0,0 +1,86 @@
# ctrlp.vim
Full path fuzzy __file__, __buffer__, __mru__, __tag__, __...__ finder for Vim.
* Written in pure Vimscript for MacVim, gVim and Vim 7.0+.
* Full support for Vim's regexp as search patterns.
* Built-in Most Recently Used (MRU) files monitoring.
* Built-in project's root finder.
* Open multiple files at once.
* Create new files and directories.
* [Extensible][2].
![ctrlp][1]
## Basic Usage
* Run `:CtrlP` or `:CtrlP [starting-directory]` to invoke CtrlP in find file mode.
* Run `:CtrlPBuffer` or `:CtrlPMRU` to invoke CtrlP in find buffer or find MRU file mode.
* Run `:CtrlPMixed` to search in Files, Buffers and MRU files at the same time.
Check `:help ctrlp-commands` and `:help ctrlp-extensions` for other commands.
##### Once CtrlP is open:
* Press `<F5>` to purge the cache for the current directory to get new files, remove deleted files and apply new ignore options.
* Press `<c-f>` and `<c-b>` to cycle between modes.
* Press `<c-d>` to switch to filename only search instead of full path.
* Press `<c-r>` to switch to regexp mode.
* Use `<c-n>`, `<c-p>` to select the next/previous string in the prompt's history.
* Use `<c-y>` to create a new file and its parent directories.
* Use `<c-z>` to mark/unmark multiple files and `<c-o>` to open them.
Run `:help ctrlp-mappings` or submit `?` in CtrlP for more mapping help.
* Submit two or more dots `..` to go up the directory tree by one or multiple levels.
* End the input string with a colon `:` followed by a command to execute it on the opening file(s):
Use `:25` to jump to line 25.
Use `:diffthis` when opening multiple files to run `:diffthis` on the first 4 files.
## Basic Options
* Change the default mapping and the default command to invoke CtrlP:
```vim
let g:ctrlp_map = '<c-p>'
let g:ctrlp_cmd = 'CtrlP'
```
* When invoked, unless a starting directory is specified, CtrlP will set its local working directory according to this variable:
```vim
let g:ctrlp_working_path_mode = 'ra'
```
`'c'` - the directory of the current file.
`'r'` - the nearest ancestor that contains one of these directories or files: `.git` `.hg` `.svn` `.bzr` `_darcs`
`'a'` - like c, but only if the current working directory outside of CtrlP is not a direct ancestor of the directory of the current file.
`0` or `''` (empty string) - disable this feature.
Define additional root markers with the `g:ctrlp_root_markers` option.
* Exclude files and directories using Vim's `wildignore` and CtrlP's own `g:ctrlp_custom_ignore`:
```vim
set wildignore+=*/tmp/*,*.so,*.swp,*.zip " MacOSX/Linux
set wildignore+=*\\tmp\\*,*.swp,*.zip,*.exe " Windows
let g:ctrlp_custom_ignore = '\v[\/]\.(git|hg|svn)$'
let g:ctrlp_custom_ignore = {
\ 'dir': '\v[\/]\.(git|hg|svn)$',
\ 'file': '\v\.(exe|so|dll)$',
\ 'link': 'some_bad_symbolic_links',
\ }
```
* Use a custom file listing command:
```vim
let g:ctrlp_user_command = 'find %s -type f' " MacOSX/Linux
let g:ctrlp_user_command = 'dir %s /-n /b /s /a-d' " Windows
```
Check `:help ctrlp-options` for other options.
## Installation
Use your favorite method or check the homepage for a [quick installation guide][3].
[1]: http://i.imgur.com/yIynr.png
[2]: https://github.com/kien/ctrlp.vim/tree/extensions
[3]: http://kien.github.com/ctrlp.vim#installation
Loading…
Cancel
Save