summaryrefslogtreecommitdiffstats
path: root/.vim/bundle/ctrlp.vim/autoload/ctrlp/mixed.vim
diff options
context:
space:
mode:
authorThibaut Horel <thibaut.horel@gmail.com>2013-02-18 23:59:52 +0100
committerThibaut Horel <thibaut.horel@gmail.com>2013-02-18 23:59:52 +0100
commit2fe3274697489afb7d547d8e42dff750ee08e510 (patch)
treefeee7bb3353f6827ca5ee3263929213ea2678446 /.vim/bundle/ctrlp.vim/autoload/ctrlp/mixed.vim
parent1637cb57b6bd91f209141efa59c7a87a18749475 (diff)
downloaddotfiles-2fe3274697489afb7d547d8e42dff750ee08e510.tar.gz
Adding two bundles
Diffstat (limited to '.vim/bundle/ctrlp.vim/autoload/ctrlp/mixed.vim')
-rw-r--r--.vim/bundle/ctrlp.vim/autoload/ctrlp/mixed.vim83
1 files changed, 83 insertions, 0 deletions
diff --git a/.vim/bundle/ctrlp.vim/autoload/ctrlp/mixed.vim b/.vim/bundle/ctrlp.vim/autoload/ctrlp/mixed.vim
new file mode 100644
index 0000000..cf01d10
--- /dev/null
+++ b/.vim/bundle/ctrlp.vim/autoload/ctrlp/mixed.vim
@@ -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