Sha256: d6c2a74974abc5203f72726f46accb83a37a718e5a65dbef556fb6bb2048cdab

Contents?: true

Size: 1.98 KB

Versions: 10

Compression:

Stored size: 1.98 KB

Contents

" =============================================================================
" File:          autoload/ctrlp/utils.vim
" Description:   Utilities
" Author:        Kien Nguyen <github.com/kien>
" =============================================================================

" Static variables {{{1
fu! ctrlp#utils#lash()
	retu &ssl || !exists('+ssl') ? '/' : '\'
endf
let s:lash = ctrlp#utils#lash()

fu! s:lash(...)
	retu match(a:0 ? a:1 : getcwd(), '[\/]$') < 0 ? s:lash : ''
endf

fu! ctrlp#utils#opts()
	let usrhome = $HOME.s:lash($HOME)
	let cahome = exists('$XDG_CACHE_HOME') ? $XDG_CACHE_HOME : usrhome.'.cache'
	let s:cache_dir = isdirectory(usrhome.'.ctrlp_cache')
		\ ? usrhome.'.ctrlp_cache' : cahome.s:lash(cahome).'ctrlp'
	if exists('g:ctrlp_cache_dir')
		let s:cache_dir = expand(g:ctrlp_cache_dir, 1)
		if isdirectory(s:cache_dir.s:lash(s:cache_dir).'.ctrlp_cache')
			let s:cache_dir = s:cache_dir.s:lash(s:cache_dir).'.ctrlp_cache'
		en
	en
endf
cal ctrlp#utils#opts()
" Files and Directories {{{1
fu! ctrlp#utils#cachedir()
	retu s:cache_dir
endf

fu! ctrlp#utils#cachefile(...)
	let [tail, dir] = [a:0 == 1 ? '.'.a:1 : '', a:0 == 2 ? a:1 : getcwd()]
	let cache_file = substitute(dir, '\([\/]\|^\a\zs:\)', '%', 'g').tail.'.txt'
	retu a:0 == 1 ? cache_file : s:cache_dir.s:lash(s:cache_dir).cache_file
endf

fu! ctrlp#utils#readfile(file)
	if filereadable(a:file)
		let data = readfile(a:file)
		if empty(data) || type(data) != 3
			unl data
			let data = []
		en
		retu data
	en
	retu []
endf

fu! ctrlp#utils#mkdir(dir)
	if exists('*mkdir') && !isdirectory(a:dir)
		sil! cal mkdir(a:dir, 'p')
	en
	retu a:dir
endf

fu! ctrlp#utils#writecache(lines, ...)
	if isdirectory(ctrlp#utils#mkdir(a:0 ? a:1 : s:cache_dir))
		sil! cal writefile(a:lines, a:0 >= 2 ? a:2 : ctrlp#utils#cachefile())
	en
endf

fu! ctrlp#utils#glob(...)
	let cond = v:version > 702 || ( v:version == 702 && has('patch051') )
	retu call('glob', cond ? a:000 : [a:1])
endf
"}}}

" vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
utils-0.0.67 lib/utils/config/vim/autoload/ctrlp/utils.vim
utils-0.0.66 lib/utils/config/vim/autoload/ctrlp/utils.vim
utils-0.0.65 lib/utils/config/vim/autoload/ctrlp/utils.vim
utils-0.0.64 lib/utils/config/vim/autoload/ctrlp/utils.vim
utils-0.0.63 lib/utils/config/vim/autoload/ctrlp/utils.vim
utils-0.0.62 lib/utils/config/vim/autoload/ctrlp/utils.vim
utils-0.0.61 lib/utils/config/vim/autoload/ctrlp/utils.vim
utils-0.0.60 lib/utils/config/vim/autoload/ctrlp/utils.vim
utils-0.0.59 lib/utils/config/vim/autoload/ctrlp/utils.vim
utils-0.0.58 lib/utils/config/vim/autoload/ctrlp/utils.vim