vundle/autoload/vundle.vim

78 lines
2.2 KiB
VimL
Raw Normal View History

2010-10-17 21:25:31 -04:00
" vundle.vim - is a shortcut for Vim Bundle and Is a simple plugin manager for Vim
" Maintainer: http://github.com/gmarik
2010-10-17 19:18:08 -04:00
" Version: 0.1
2010-10-17 21:25:31 -04:00
" Readme: http://github.com/gmarik/vundle/blob/master/README.md
2010-10-17 19:18:08 -04:00
if exists("g:vundle_loaded") || &cp | finish | endif
let g:vundle_loaded = 1
2010-10-17 20:46:09 -04:00
com! -nargs=+ Bundle call vundle#add_bundle(<args>)
com! -nargs=0 BundleRequire call vundle#require_bundles()
com! -nargs=0 BundleSync call vundle#sync_bundles()
com! -nargs=0 BundleInstall call vundle#install_bundles()
2010-10-17 19:18:08 -04:00
let g:bundle_dir = expand('~/.vim/bundle/')
let g:bundles = []
let g:bundle_uris = {}
2010-10-18 22:41:11 -04:00
func! vundle#add_bundle(...)
2010-10-17 19:18:08 -04:00
let bundle = split(a:1,'\/')[-1]
call add(g:bundles, bundle)
let g:bundle_uris[bundle] = a:1
2010-10-18 22:41:11 -04:00
endf
2010-10-17 19:18:08 -04:00
2010-10-19 00:08:57 -04:00
func! vundle#rc(...)
exec 'silent! so '.expand('~/.vim/bundlerc')
call vundle#require_bundles()
endf
2010-10-18 22:41:11 -04:00
func! vundle#require_bundles()
2010-10-17 19:18:08 -04:00
let rtp = filter(split(&rtp, ','),'v:val !~# g:bundle_dir')
let after = [] | let before = []
for bundle in g:bundles
let path = s:BundleRuntime(bundle)
let before += path[0] | let after += path[1]
endfor
let &rtp = join(before + rtp + after, ',')
2010-10-18 22:41:11 -04:00
endf
2010-10-17 19:18:08 -04:00
2010-10-18 22:41:11 -04:00
func! vundle#install_bundles()
2010-10-17 21:18:40 -04:00
call vundle#sync_bundles()
call vundle#helptagify_bundles()
2010-10-18 22:41:11 -04:00
endf
2010-10-17 19:18:08 -04:00
2010-10-18 22:41:11 -04:00
func! vundle#sync_bundles()
2010-10-17 20:25:17 -04:00
execute '!mkdir -p '.g:bundle_dir
2010-10-17 19:18:08 -04:00
for bundle in g:bundles
let bundle_path = s:BundlePath(bundle)
let bundle_uri = g:bundle_uris[bundle]
2010-10-18 22:37:10 -04:00
let git_dir = bundle_path.'/.git'
let cmd = isdirectory(git_dir) ?
\ '--git-dir='.git_dir.' pull' :
\ 'clone '.bundle_uri.' '.bundle_path
exec '!echo -ne "* '.bundle.'"'
exec '!git '.cmd
2010-10-17 19:18:08 -04:00
endfor
2010-10-18 22:41:11 -04:00
endf
2010-10-17 19:18:08 -04:00
2010-10-18 22:41:11 -04:00
func! vundle#helptagify_bundles()
2010-10-17 19:18:08 -04:00
for bundle in g:bundles
let dir = s:BundlePath(bundle)
if isdirectory(dir.'/doc') && (!filereadable(dir.'/doc/tags') || filewritable(dir.'/doc/tags'))
helptags `=dir.'/doc'`
endif
endfor
2010-10-18 22:41:11 -04:00
endf
2010-10-17 19:18:08 -04:00
2010-10-18 22:41:11 -04:00
func! s:BundlePath(bundle_name)
2010-10-17 19:18:08 -04:00
return expand(g:bundle_dir.a:bundle_name)
2010-10-18 22:41:11 -04:00
endf
2010-10-17 19:18:08 -04:00
2010-10-18 22:41:11 -04:00
func! s:BundleRuntime(bundle_name) " {{{1
2010-10-17 19:18:08 -04:00
let bundle_path = s:BundlePath(a:bundle_name)
let before = [bundle_path] | let after = []
let after_dir = expand(bundle_path.'/'.'after')
if isdirectory(after_dir) | let after = [after_dir] | endif
return [before, after]
2010-10-18 22:41:11 -04:00
endf " }}}