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-12-06 00:17:27 -05:00
|
|
|
" Version: 0.4
|
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
|
|
|
|
2010-11-26 13:33:17 -05:00
|
|
|
com! -nargs=+ Bundle call vundle#add_bundle(<args>)
|
|
|
|
com! -nargs=0 BundleInstall call vundle#install_bundles()
|
2010-12-05 23:44:28 -05:00
|
|
|
com! -nargs=0 BundleDocs call vundle#helptags()
|
2010-10-17 19:18:08 -04:00
|
|
|
|
2010-11-26 13:33:17 -05:00
|
|
|
com! -nargs=+ -bang BundleSearch silent call vundle#scripts#search("<bang>", <q-args>)
|
2010-10-17 19:18:08 -04:00
|
|
|
|
2010-10-31 23:02:20 -04:00
|
|
|
func! vundle#rc()
|
2010-11-02 23:11:20 -04:00
|
|
|
let g:bundle_dir = expand('$HOME/.vim/bundle/')
|
2010-10-31 23:02:20 -04:00
|
|
|
let g:bundles = []
|
2010-10-18 22:41:11 -04:00
|
|
|
endf
|
2010-10-17 19:18:08 -04:00
|
|
|
|
2010-12-05 23:44:28 -05:00
|
|
|
func! vundle#add_bundle(arg, ...)
|
2010-12-06 00:16:29 -05:00
|
|
|
let bundle = s:parse_options(a:000)
|
2010-12-05 23:44:28 -05:00
|
|
|
call add(g:bundles, bundle)
|
2010-12-06 00:16:29 -05:00
|
|
|
call extend(bundle, s:parse_name(a:arg))
|
|
|
|
call extend(bundle, copy(s:bundle))
|
2010-12-07 21:20:20 -05:00
|
|
|
call s:rtp_add(bundle.rtpath())
|
2010-10-19 00:08:57 -04:00
|
|
|
endf
|
|
|
|
|
2010-12-05 23:44:28 -05:00
|
|
|
func! vundle#install_bundles()
|
|
|
|
silent source ~/.vimrc
|
|
|
|
exec '!mkdir -p '.g:bundle_dir
|
2010-12-07 21:28:40 -05:00
|
|
|
for bundle in g:bundles | call s:install(bundle) | endfor
|
2010-12-07 21:43:23 -05:00
|
|
|
echo 'Done'
|
2010-11-02 23:11:20 -04:00
|
|
|
endf
|
|
|
|
|
2010-12-05 23:44:28 -05:00
|
|
|
func! vundle#helptags()
|
2010-12-07 21:43:23 -05:00
|
|
|
let c = 0
|
|
|
|
for bundle in g:bundles | let c += s:helptags(bundle.rtpath()) | endfor
|
2010-12-07 21:45:32 -05:00
|
|
|
echo 'Done. '.c.' bundles processed'
|
2010-11-02 23:11:20 -04:00
|
|
|
endf
|
|
|
|
|
2010-12-07 21:20:20 -05:00
|
|
|
func! s:rtp_add(dir)
|
|
|
|
exec 'set rtp^='.a:dir
|
|
|
|
let after = expand(a:dir.'/after') | if isdirectory(after)
|
|
|
|
exec 'set rtp+='.after
|
|
|
|
endif
|
|
|
|
endf
|
|
|
|
|
2010-12-07 20:54:12 -05:00
|
|
|
func! s:parse_options(opts)
|
2010-12-06 00:16:29 -05:00
|
|
|
" TODO: improve this
|
|
|
|
if len(a:opts) != 1 | return {} | endif
|
|
|
|
|
|
|
|
if type(a:opts[0]) == type({})
|
|
|
|
return a:opts[0]
|
|
|
|
else
|
|
|
|
return {'rev': a:opts[0]}
|
|
|
|
endif
|
|
|
|
endf
|
|
|
|
|
|
|
|
func! s:parse_name(arg)
|
|
|
|
let arg = a:arg
|
|
|
|
if arg =~ '^\s*\(git@\|git://\)\S\+' || arg =~ 'https\?://' || arg =~ '\.git\*$'
|
|
|
|
let uri = arg
|
|
|
|
let name = substitute(split(uri,'\/')[-1], '\.git\s*$','','i')
|
|
|
|
else
|
|
|
|
let name = arg
|
|
|
|
let uri = 'http://github.com/vim-scripts/'.name.'.git'
|
|
|
|
endif
|
|
|
|
return {'name': name, 'uri': uri }
|
|
|
|
endf
|
|
|
|
|
2010-12-07 21:43:23 -05:00
|
|
|
func! s:helptags(rtp)
|
|
|
|
if !(isdirectory(a:rtp.'/doc') && (!filereadable(a:rtp.'/doc/tags') || filewritable(a:rtp.'/doc/tags')))
|
|
|
|
return 0
|
2010-12-05 23:44:28 -05:00
|
|
|
endif
|
2010-12-07 21:43:23 -05:00
|
|
|
helptags `=a:rtp.'/doc'`
|
|
|
|
return 1
|
2010-12-05 23:44:28 -05:00
|
|
|
endf
|
|
|
|
|
2010-12-07 21:28:40 -05:00
|
|
|
func! s:sync(bundle)
|
|
|
|
let git_dir = a:bundle.path().'/.git'
|
2010-12-05 23:44:28 -05:00
|
|
|
if isdirectory(git_dir)
|
2010-12-07 21:28:40 -05:00
|
|
|
silent exec '!cd '.a:bundle.path().'; git pull'
|
2010-12-05 23:44:28 -05:00
|
|
|
else
|
2010-12-07 21:28:40 -05:00
|
|
|
silent exec '!git clone '.a:bundle.uri.' '.a:bundle.path()
|
2010-12-05 23:44:28 -05:00
|
|
|
endif
|
|
|
|
endf
|
|
|
|
|
2010-12-07 21:28:40 -05:00
|
|
|
func! s:install(bundle)
|
2010-12-07 22:04:32 -05:00
|
|
|
echo a:bundle.name
|
|
|
|
call s:sync(a:bundle)
|
|
|
|
call s:helptags(a:bundle.rtpath())
|
|
|
|
exec 'runtime! '.a:bundle.rtpath().'/plugin/*.vim'
|
2010-12-07 21:28:40 -05:00
|
|
|
endf
|
|
|
|
|
|
|
|
let s:bundle = {}
|
|
|
|
|
|
|
|
func! s:bundle.path()
|
|
|
|
return expand(g:bundle_dir.''.self.name)
|
|
|
|
endf
|
|
|
|
|
|
|
|
func! s:bundle.rtpath()
|
|
|
|
return has_key(self, 'rtp') ? join([self.path(), self.rtp], '/') : self.path()
|
2010-10-18 22:41:11 -04:00
|
|
|
endf
|