comparison vim/vimfiles/autoload/ctrlp/dir.vim @ 0:48859d9c82c5

Initial commit, based on settings used at work (minus NERD tree & some tagging plugins).
author Brian Neal <bgneal@gmail.com>
date Tue, 03 Jan 2012 20:53:13 -0600
parents
children 92af3257a261
comparison
equal deleted inserted replaced
-1:000000000000 0:48859d9c82c5
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:folsym',
15 \ 's:dotfiles',
16 \ 's:maxdepth',
17 \ 's:maxfiles',
18 \ 's:compare_lim',
19 \ 's:glob',
20 \ ]
21
22 let s:dir_var = ['ctrlp#dir#init('.join(s:ars, ', ').')', 'ctrlp#dir#accept',
23 \ 'dirs', 'dir']
24
25 let g:ctrlp_ext_vars = exists('g:ctrlp_ext_vars') && !empty(g:ctrlp_ext_vars)
26 \ ? add(g:ctrlp_ext_vars, s:dir_var) : [s:dir_var]
27
28 let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars)
29 " Utilities {{{1
30 fu! s:globdirs(dirs, depth)
31 let entries = split(globpath(a:dirs, s:glob), "\n")
32 if !s:folsym
33 let entries = filter(entries, 'getftype(v:val) != "link"')
34 en
35 let ftrfunc = s:dotfiles ? 'ctrlp#dirfilter(v:val)' : 'isdirectory(v:val)'
36 let alldirs = filter(entries, ftrfunc)
37 cal extend(g:ctrlp_alldirs, alldirs)
38 let depth = a:depth + 1
39 if !empty(g:ctrlp_alldirs) && !s:max(len(g:ctrlp_alldirs), s:maxfiles)
40 \ && depth <= s:maxdepth
41 sil! cal ctrlp#progress(len(g:ctrlp_alldirs))
42 cal s:globdirs(join(alldirs, ','), depth)
43 en
44 endf
45
46 fu! s:max(len, max)
47 retu a:max && a:len > a:max ? 1 : 0
48 endf
49 " Public {{{1
50 fu! ctrlp#dir#init(...)
51 let s:cwd = getcwd()
52 for each in range(len(s:ars))
53 exe 'let' s:ars[each] '=' string(eval('a:'.(each + 1)))
54 endfo
55 let cadir = ctrlp#utils#cachedir().ctrlp#utils#lash().s:dir_var[3]
56 let cafile = cadir.ctrlp#utils#lash().ctrlp#utils#cachefile(s:dir_var[3])
57 if g:ctrlp_newdir || !filereadable(cafile)
58 let g:ctrlp_alldirs = []
59 cal s:globdirs(s:cwd, 0)
60 cal ctrlp#rmbasedir(g:ctrlp_alldirs)
61 let read_cache = 0
62 el
63 let g:ctrlp_alldirs = ctrlp#utils#readfile(cafile)
64 let read_cache = 1
65 en
66 if len(g:ctrlp_alldirs) <= s:compare_lim
67 cal sort(g:ctrlp_alldirs, 'ctrlp#complen')
68 en
69 if !read_cache
70 cal ctrlp#utils#writecache(g:ctrlp_alldirs, cadir, cafile)
71 let g:ctrlp_newdir = 0
72 en
73 retu g:ctrlp_alldirs
74 endf
75
76 fu! ctrlp#dir#accept(mode, str)
77 let path = a:mode == 'h' ? getcwd() : s:cwd.ctrlp#utils#lash().a:str
78 if a:mode =~ 't\|v\|h'
79 cal ctrlp#exit()
80 en
81 cal ctrlp#setdir(path, a:mode =~ 't\|h' ? 'chd!' : 'lc!')
82 if a:mode == 'e'
83 sil! cal ctrlp#statusline()
84 cal ctrlp#setlines(s:id)
85 cal ctrlp#recordhist()
86 cal ctrlp#prtclear()
87 en
88 endf
89
90 fu! ctrlp#dir#id()
91 retu s:id
92 endf
93 "}}}
94
95 " vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2