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