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-19 00:40:26 -04:00
|
|
|
au BufRead,BufNewFile {bundlerc} set ft=vim
|
|
|
|
|
2010-10-30 20:42:07 -04:00
|
|
|
com! -nargs=+ Bundle call vundle#add_and_require_bundle(<args>)
|
2010-10-17 20:46:09 -04:00
|
|
|
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 = []
|
|
|
|
|
2010-10-30 20:42:07 -04:00
|
|
|
func! vundle#add_bundle(uri, opts)
|
|
|
|
let bundle = a:opts
|
2010-10-31 03:13:20 -04:00
|
|
|
let bundle.uri = a:uri
|
2010-10-30 20:42:07 -04:00
|
|
|
let bundle.name = split(a:uri,'\/')[-1] " potentially break on Windows
|
|
|
|
let bundle.path = expand(g:bundle_dir.''.bundle.name)
|
2010-10-30 02:13:58 -04:00
|
|
|
let bundle.rtpath = has_key(bundle, 'rtp') ? join([bundle.path, bundle.rtp], '/') : bundle.path
|
2010-10-17 19:18:08 -04:00
|
|
|
call add(g:bundles, bundle)
|
2010-10-30 20:42:07 -04:00
|
|
|
return bundle
|
2010-10-18 22:41:11 -04:00
|
|
|
endf
|
2010-10-17 19:18:08 -04:00
|
|
|
|
2010-10-30 20:42:07 -04:00
|
|
|
func! vundle#add_and_require_bundle(...)
|
|
|
|
let [uri; rest] = a:000 | let opts = {}
|
|
|
|
if len(rest) == 1 | let opts = rest[0] | endif
|
|
|
|
let bundle = vundle#add_bundle(uri, opts)
|
|
|
|
call vundle#require_bundle(bundle)
|
2010-10-19 00:08:57 -04:00
|
|
|
endf
|
|
|
|
|
2010-10-30 20:42:07 -04:00
|
|
|
func! vundle#rc()
|
|
|
|
let &rtp = join(filter(split(&rtp, ','),'v:val !~# g:bundle_dir'), ',')
|
2010-10-31 03:14:14 -04:00
|
|
|
let g:bundles = []
|
2010-10-30 20:42:07 -04:00
|
|
|
endf
|
|
|
|
|
|
|
|
func! vundle#require_bundle(bundle)
|
2010-10-31 03:13:20 -04:00
|
|
|
let rtp = filter(split(&rtp, ','),'v:val !~# a:bundle.path')
|
2010-10-17 19:18:08 -04:00
|
|
|
let after = [] | let before = []
|
2010-10-31 03:13:20 -04:00
|
|
|
let path = s:RuntimePath(a:bundle)
|
2010-10-30 20:42:07 -04:00
|
|
|
let before += path[0] | let after += path[1]
|
2010-10-17 19:18:08 -04:00
|
|
|
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-30 20:42:07 -04:00
|
|
|
exec '!mkdir -p '.g:bundle_dir
|
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 19:18:08 -04:00
|
|
|
for bundle in g:bundles
|
2010-10-30 02:13:58 -04:00
|
|
|
let git_dir = bundle.path.'/.git'
|
2010-10-18 22:37:10 -04:00
|
|
|
let cmd = isdirectory(git_dir) ?
|
|
|
|
\ '--git-dir='.git_dir.' pull' :
|
2010-10-30 02:13:58 -04:00
|
|
|
\ 'clone '.bundle.uri.' '.bundle.path
|
|
|
|
exec '!echo -ne "* '.bundle.name.'"'
|
2010-10-18 22:37:10 -04:00
|
|
|
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
|
2010-10-30 02:13:58 -04:00
|
|
|
let dir = bundle.path
|
2010-10-17 19:18:08 -04:00
|
|
|
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-30 20:42:07 -04:00
|
|
|
func! s:RuntimePath(bundle)
|
2010-10-30 02:13:58 -04:00
|
|
|
let before = [a:bundle.rtpath] | let after = []
|
|
|
|
let after_dir = expand(a:bundle.rtpath.'/'.'after')
|
2010-10-17 19:18:08 -04:00
|
|
|
if isdirectory(after_dir) | let after = [after_dir] | endif
|
|
|
|
return [before, after]
|
2010-10-30 02:13:58 -04:00
|
|
|
endf
|