comparison vim/vimfiles/bundle/ctrlp.vim/autoload/ctrlp/mixed.vim @ 7:86e0ac713642

Re-added the latest ctrlp.vim plugin. The ctrlp.vim commit was e61e7d5b801ade5fcefeab3aca75c1f37d54bdf1.
author Brian Neal <bgneal@gmail.com>
date Sun, 29 Apr 2012 16:20:31 -0500
parents
children
comparison
equal deleted inserted replaced
6:ff60fbc930de 7:86e0ac713642
1 " =============================================================================
2 " File: autoload/ctrlp/mixed.vim
3 " Description: Mixing Files + MRU + Buffers
4 " Author: Kien Nguyen <github.com/kien>
5 " =============================================================================
6
7 " Init {{{1
8 if exists('g:loaded_ctrlp_mixed') && g:loaded_ctrlp_mixed
9 fini
10 en
11 let [g:loaded_ctrlp_mixed, g:ctrlp_newmix] = [1, 0]
12
13 cal add(g:ctrlp_ext_vars, {
14 \ 'init': 'ctrlp#mixed#init(s:compare_lim)',
15 \ 'accept': 'ctrlp#acceptfile',
16 \ 'lname': 'fil + mru + buf',
17 \ 'sname': 'mix',
18 \ 'type': 'path',
19 \ 'opmul': 1,
20 \ 'specinput': 1,
21 \ })
22
23 let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars)
24 " Utilities {{{1
25 fu! s:newcache(cwd)
26 if g:ctrlp_newmix || !has_key(g:ctrlp_allmixes, 'data') | retu 1 | en
27 retu g:ctrlp_allmixes['cwd'] != a:cwd
28 \ || g:ctrlp_allmixes['filtime'] < getftime(ctrlp#utils#cachefile())
29 \ || g:ctrlp_allmixes['mrutime'] < getftime(ctrlp#mrufiles#cachefile())
30 \ || g:ctrlp_allmixes['bufs'] < len(ctrlp#mrufiles#bufs())
31 endf
32
33 fu! s:getnewmix(cwd, clim)
34 if g:ctrlp_newmix
35 cal ctrlp#mrufiles#refresh('raw')
36 let g:ctrlp_newcache = 1
37 en
38 let g:ctrlp_lines = copy(ctrlp#files())
39 cal ctrlp#progress('Mixing...')
40 let mrufs = copy(ctrlp#mrufiles#list('raw'))
41 if exists('+ssl') && &ssl
42 cal map(mrufs, 'tr(v:val, "\\", "/")')
43 en
44 let bufs = map(ctrlp#buffers('id'), 'fnamemodify(bufname(v:val), ":p")')
45 let mrufs = bufs + filter(mrufs, 'index(bufs, v:val) < 0')
46 if len(mrufs) > len(g:ctrlp_lines)
47 cal filter(mrufs, 'stridx(v:val, a:cwd)')
48 el
49 let cwd_mrufs = filter(copy(mrufs), '!stridx(v:val, a:cwd)')
50 let cwd_mrufs = ctrlp#rmbasedir(cwd_mrufs)
51 for each in cwd_mrufs
52 let id = index(g:ctrlp_lines, each)
53 if id >= 0 | cal remove(g:ctrlp_lines, id) | en
54 endfo
55 en
56 cal map(mrufs, 'fnamemodify(v:val, ":.")')
57 let g:ctrlp_lines = len(mrufs) > len(g:ctrlp_lines)
58 \ ? g:ctrlp_lines + mrufs : mrufs + g:ctrlp_lines
59 if len(g:ctrlp_lines) <= a:clim
60 cal sort(g:ctrlp_lines, 'ctrlp#complen')
61 en
62 let g:ctrlp_allmixes = { 'filtime': getftime(ctrlp#utils#cachefile()),
63 \ 'mrutime': getftime(ctrlp#mrufiles#cachefile()), 'cwd': a:cwd,
64 \ 'bufs': len(ctrlp#mrufiles#bufs()), 'data': g:ctrlp_lines }
65 endf
66 " Public {{{1
67 fu! ctrlp#mixed#init(clim)
68 let cwd = getcwd()
69 if s:newcache(cwd)
70 cal s:getnewmix(cwd, a:clim)
71 el
72 let g:ctrlp_lines = g:ctrlp_allmixes['data']
73 en
74 let g:ctrlp_newmix = 0
75 retu g:ctrlp_lines
76 endf
77
78 fu! ctrlp#mixed#id()
79 retu s:id
80 endf
81 "}}}
82
83 " vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2