annotate vim/vimfiles/bundle/ctrlp.vim/autoload/ctrlp/mixed.vim @ 18:2cc96559ecac

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