comparison vim/vimfiles/autoload/ctrlp/utils.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/utils.vim
3 " Description: Utilities
4 " Author: Kien Nguyen <github.com/kien>
5 " =============================================================================
6
7 " Static variables {{{1
8 fu! ctrlp#utils#lash()
9 retu &ssl || !exists('+ssl') ? '/' : '\'
10 endf
11 let s:lash = ctrlp#utils#lash()
12
13 fu! ctrlp#utils#opts()
14 let s:cache_dir = $HOME.s:lash.'.ctrlp_cache'
15 if exists('g:ctrlp_cache_dir')
16 let s:cache_dir = expand(g:ctrlp_cache_dir, 1)
17 if isdirectory(s:cache_dir.s:lash.'.ctrlp_cache')
18 let s:cache_dir = s:cache_dir.s:lash.'.ctrlp_cache'
19 en
20 en
21 endf
22 cal ctrlp#utils#opts()
23 " Files and Directories {{{1
24 fu! ctrlp#utils#cachedir()
25 retu s:cache_dir
26 endf
27
28 fu! ctrlp#utils#cachefile(...)
29 let tail = exists('a:1') ? '.'.a:1 : ''
30 let cache_file = substitute(getcwd(), '\([\/]\|^\a\zs:\)', '%', 'g').tail.'.txt'
31 retu exists('a:1') ? cache_file : s:cache_dir.s:lash.cache_file
32 endf
33
34 fu! ctrlp#utils#readfile(file)
35 if filereadable(a:file)
36 let data = readfile(a:file)
37 if empty(data) || type(data) != 3
38 unl data
39 let data = []
40 en
41 retu data
42 en
43 retu []
44 endf
45
46 fu! ctrlp#utils#mkdir(dir)
47 if exists('*mkdir') && !isdirectory(a:dir)
48 sil! cal mkdir(a:dir)
49 en
50 endf
51
52 fu! ctrlp#utils#writecache(lines, ...)
53 let cache_dir = exists('a:1') ? a:1 : s:cache_dir
54 cal ctrlp#utils#mkdir(cache_dir)
55 if isdirectory(cache_dir)
56 sil! cal writefile(a:lines, exists('a:2') ? a:2 : ctrlp#utils#cachefile())
57 if !exists('a:1')
58 let g:ctrlp_newcache = 0
59 en
60 en
61 endf
62
63 fu! ctrlp#utils#glob(...)
64 retu call('glob', v:version > 701 ? a:000 : a:1)
65 endf
66 "}}}
67
68 " vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2