vundle/autoload/vundle.vim

85 lines
2.4 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-11-02 23:11:20 -04:00
" Version: 0.2
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-02 23:11:20 -04:00
com! -nargs=+ Bundle call vundle#add_bundle(<args>)
2010-10-17 20:46:09 -04:00
com! -nargs=0 BundleInstall call vundle#install_bundles()
2010-11-02 23:11:20 -04:00
com! -nargs=0 BundleDocs call vundle#helptagify_bundles()
2010-10-17 19:18:08 -04:00
2010-11-24 17:15:16 -05:00
com! -nargs=* BundleSearch silent call vundle#scripts#search(<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-10-31 23:02:20 -04:00
func! vundle#add_bundle(...)
2010-11-02 23:11:20 -04:00
let [arg; rest] = a:000 | let opts = {}
if len(rest) == 1 | let opts = rest[0] | endif
2010-11-02 23:11:20 -04:00
" try
let bundle = vundle#new_bundle(arg, opts)
call vundle#require_bundle(bundle)
" catch | echo 'Error: loadin '.arg | endtry
2010-10-19 00:08:57 -04:00
endf
2010-11-02 23:11:20 -04:00
func! vundle#init_bundle(arg, opts)
let bundle = a:opts | let arg = a:arg
2010-11-24 17:15:16 -05:00
if arg =~ '^\s*\(git@\|git://\)\S\+' || arg =~ 'https\?://' || arg =~ '\.git\*$'
2010-11-02 23:11:20 -04:00
let bundle.uri = arg
let bundle.name = substitute(split(bundle.uri,'\/')[-1], '\.git\s*$','','i')
else
let bundle.name = arg
let bundle.uri = vundle#script_uri(bundle.name)
endif
return bundle
endf
func! vundle#script_uri(name)
return 'http://github.com/vim-scripts/'.a:name.'.git'
endf
func! vundle#new_bundle(arg, opts)
let bundle = vundle#init_bundle(a:arg, a:opts)
2010-10-31 23:02:20 -04:00
let bundle.path = expand(g:bundle_dir.''.bundle.name)
let bundle.rtpath = has_key(bundle, 'rtp') ? join([bundle.path, bundle.rtp], '/') : bundle.path
call add(g:bundles, bundle)
return bundle
endf
func! vundle#require_bundle(bundle)
2010-10-31 23:02:20 -04:00
let dir = a:bundle.rtpath
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-10-18 22:41:11 -04:00
func! vundle#install_bundles()
2010-11-03 00:52:09 -04:00
silent source ~/.vimrc
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-31 20:32:39 -04:00
let dir = bundle.rtpath
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-11-02 23:11:20 -04:00