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-11-26 13:36:23 -05:00
|
|
|
" Version: 0.3
|
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-05 23:44:28 -05:00
|
|
|
call bundle.require()
|
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
|
|
|
|
for bundle in g:bundles | call bundle.install() | endfor
|
2010-11-02 23:11:20 -04:00
|
|
|
endf
|
|
|
|
|
2010-12-05 23:44:28 -05:00
|
|
|
func! vundle#helptags()
|
|
|
|
for bundle in g:bundles | call bundle.helptags() | endfor
|
2010-11-02 23:11:20 -04:00
|
|
|
endf
|
|
|
|
|
2010-12-06 00:16:29 -05:00
|
|
|
func s:parse_options(opts)
|
|
|
|
" 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-05 23:44:28 -05:00
|
|
|
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-30 20:42:07 -04:00
|
|
|
endf
|
|
|
|
|
2010-12-05 23:44:28 -05:00
|
|
|
func s:bundle.require()
|
|
|
|
let dir = self.rtpath()
|
2010-10-31 23:02:20 -04:00
|
|
|
exec 'set rtp^='.dir
|
|
|
|
let after = expand(dir.'/after') | if isdirectory(after)
|
|
|
|
exec 'set rtp+='.after
|
|
|
|
endif
|
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! s:bundle.helptags()
|
|
|
|
let dir = self.rtpath()
|
|
|
|
if isdirectory(dir.'/doc') && (!filereadable(dir.'/doc/tags') || filewritable(dir.'/doc/tags'))
|
|
|
|
helptags `=dir.'/doc'`
|
|
|
|
endif
|
|
|
|
endf
|
|
|
|
|
|
|
|
func! s:bundle.sync()
|
|
|
|
let git_dir = self.path().'/.git'
|
|
|
|
exec '!echo -ne "* '.self.name.'"'
|
|
|
|
if isdirectory(git_dir)
|
|
|
|
silent exec '!cd '.self.path().'; git pull'
|
|
|
|
else
|
|
|
|
silent exec '!git clone '.self.uri.' '.self.path()
|
|
|
|
endif
|
|
|
|
endf
|
|
|
|
|
|
|
|
func! s:bundle.install()
|
|
|
|
call self.sync()
|
|
|
|
call self.helptags()
|
2010-10-18 22:41:11 -04:00
|
|
|
endf
|