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