annotate vim/vimfiles/bundle/ctrlp.vim/autoload/ctrlp/dir.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/dir.vim
bgneal@7 3 " Description: Directory extension
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_dir') && g:loaded_ctrlp_dir
bgneal@7 9 fini
bgneal@7 10 en
bgneal@7 11 let [g:loaded_ctrlp_dir, g:ctrlp_newdir] = [1, 0]
bgneal@7 12
bgneal@7 13 let s:ars = [
bgneal@7 14 \ 's:maxdepth',
bgneal@7 15 \ 's:maxfiles',
bgneal@7 16 \ 's:compare_lim',
bgneal@7 17 \ 's:glob',
bgneal@7 18 \ ]
bgneal@7 19
bgneal@7 20 cal add(g:ctrlp_ext_vars, {
bgneal@7 21 \ 'init': 'ctrlp#dir#init('.join(s:ars, ', ').')',
bgneal@7 22 \ 'accept': 'ctrlp#dir#accept',
bgneal@7 23 \ 'lname': 'dirs',
bgneal@7 24 \ 'sname': 'dir',
bgneal@7 25 \ 'type': 'path',
bgneal@7 26 \ 'specinput': 1,
bgneal@7 27 \ })
bgneal@7 28
bgneal@7 29 let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars)
bgneal@7 30 " Utilities {{{1
bgneal@7 31 fu! s:globdirs(dirs, depth)
bgneal@7 32 let entries = split(globpath(a:dirs, s:glob), "\n")
bgneal@7 33 let [dirs, depth] = [ctrlp#dirnfile(entries)[0], a:depth + 1]
bgneal@7 34 cal extend(g:ctrlp_alldirs, dirs)
bgneal@7 35 let nr = len(g:ctrlp_alldirs)
bgneal@7 36 if !empty(dirs) && !s:max(nr, s:maxfiles) && depth <= s:maxdepth
bgneal@7 37 sil! cal ctrlp#progress(nr)
bgneal@7 38 cal s:globdirs(join(dirs, ','), depth)
bgneal@7 39 en
bgneal@7 40 endf
bgneal@7 41
bgneal@7 42 fu! s:max(len, max)
bgneal@7 43 retu a:max && a:len > a:max ? 1 : 0
bgneal@7 44 endf
bgneal@7 45 " Public {{{1
bgneal@7 46 fu! ctrlp#dir#init(...)
bgneal@7 47 let s:cwd = getcwd()
bgneal@7 48 for each in range(len(s:ars))
bgneal@7 49 let {s:ars[each]} = a:{each + 1}
bgneal@7 50 endfo
bgneal@7 51 let cadir = ctrlp#utils#cachedir().ctrlp#utils#lash().'dir'
bgneal@7 52 let cafile = cadir.ctrlp#utils#lash().ctrlp#utils#cachefile('dir')
bgneal@7 53 if g:ctrlp_newdir || !filereadable(cafile)
bgneal@7 54 let [s:initcwd, g:ctrlp_alldirs] = [s:cwd, []]
bgneal@7 55 cal s:globdirs(s:cwd, 0)
bgneal@7 56 cal ctrlp#rmbasedir(g:ctrlp_alldirs)
bgneal@7 57 if len(g:ctrlp_alldirs) <= s:compare_lim
bgneal@7 58 cal sort(g:ctrlp_alldirs, 'ctrlp#complen')
bgneal@7 59 en
bgneal@7 60 cal ctrlp#utils#writecache(g:ctrlp_alldirs, cadir, cafile)
bgneal@7 61 let g:ctrlp_newdir = 0
bgneal@7 62 el
bgneal@7 63 if !( exists('s:initcwd') && s:initcwd == s:cwd )
bgneal@7 64 let s:initcwd = s:cwd
bgneal@7 65 let g:ctrlp_alldirs = ctrlp#utils#readfile(cafile)
bgneal@7 66 en
bgneal@7 67 en
bgneal@7 68 retu g:ctrlp_alldirs
bgneal@7 69 endf
bgneal@7 70
bgneal@7 71 fu! ctrlp#dir#accept(mode, str)
bgneal@7 72 let path = a:mode == 'h' ? getcwd() : s:cwd.ctrlp#utils#lash().a:str
bgneal@7 73 if a:mode =~ 't\|v\|h'
bgneal@7 74 cal ctrlp#exit()
bgneal@7 75 en
bgneal@7 76 cal ctrlp#setdir(path, a:mode =~ 't\|h' ? 'chd!' : 'lc!')
bgneal@7 77 if a:mode == 'e'
bgneal@7 78 sil! cal ctrlp#statusline()
bgneal@7 79 cal ctrlp#setlines(s:id)
bgneal@7 80 cal ctrlp#recordhist()
bgneal@7 81 cal ctrlp#prtclear()
bgneal@7 82 en
bgneal@7 83 endf
bgneal@7 84
bgneal@7 85 fu! ctrlp#dir#id()
bgneal@7 86 retu s:id
bgneal@7 87 endf
bgneal@7 88 "}}}
bgneal@7 89
bgneal@7 90 " vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2