From 8955c848cb6682e8677493309b2d614af3737a26 Mon Sep 17 00:00:00 2001 From: gmarik Date: Wed, 8 Dec 2010 21:26:38 -0600 Subject: [PATCH] Enable plugins without restarting Vim! --- autoload/vundle.vim | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/autoload/vundle.vim b/autoload/vundle.vim index 3622cea..fd9e663 100644 --- a/autoload/vundle.vim +++ b/autoload/vundle.vim @@ -9,8 +9,12 @@ com! -nargs=0 BundleDocs call vundle#helptags() com! -nargs=+ -bang BundleSearch silent call vundle#scripts#search("", ) +if !exists('g:bundles') | let g:bundles = [] | endif + func! vundle#rc() - let g:bundle_dir = expand('$HOME/.vim/bundle/') + let g:bundle_dir = expand('$HOME/.vim/bundle') + call filter(g:bundles, 's:rtp_rm(v:val.rtpath())') + call s:rtp_rm(g:bundle_dir) let g:bundles = [] endf @@ -19,6 +23,8 @@ func! vundle#add_bundle(arg, ...) call extend(bundle, copy(s:bundle)) call add(g:bundles, bundle) call s:rtp_add(bundle.rtpath()) + call s:rtp_add(g:bundle_dir) + exec 'runtime! '.bundle.name.'/plugin/*.vim' endf func! vundle#install_bundles(bang) @@ -33,13 +39,6 @@ func! vundle#helptags() echo 'Done. '.c.' bundles processed' endf -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 - func! s:parse_options(opts) " TODO: improve this if len(a:opts) != 1 | return {} | endif @@ -88,10 +87,20 @@ func! s:install(bang, bundle) call s:helptags(a:bundle.rtpath()) endf +func! s:rtp_rm(dir) + exec 'set rtp-='.a:dir + exec 'set rtp-='.expand(a:dir.'/after') +endf + +func! s:rtp_add(dir) + exec 'set rtp^='.a:dir + exec 'set rtp+='.expand(a:dir.'/after') +endf + let s:bundle = {} func! s:bundle.path() - return expand(g:bundle_dir.''.self.name) + return join([g:bundle_dir, self.name], '/') endf func! s:bundle.rtpath()