From c20c90d86761c8e164ae51eb97b13b0f6d9c8adf Mon Sep 17 00:00:00 2001 From: Jacobo de Vera Date: Mon, 7 Apr 2014 00:59:23 +0200 Subject: [PATCH] Lazy loading plugins with begin/end block --- autoload/vundle.vim | 10 ++++++++++ autoload/vundle/config.vim | 14 +++++++++++--- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/autoload/vundle.vim b/autoload/vundle.vim index 16eebca..83d6c90 100644 --- a/autoload/vundle.vim +++ b/autoload/vundle.vim @@ -64,3 +64,13 @@ func! vundle#rc(...) abort let g:vundle_changelog = ['Updated Plugins:'] call vundle#config#init() endf + +func! vundle#begin(...) abort + let g:vundle_lazy_load = 1 + call call('vundle#rc', a:000) +endf + +func! vundle#end(...) abort + unlet g:vundle_lazy_load + call vundle#config#activate_bundles() +endf diff --git a/autoload/vundle/config.vim b/autoload/vundle/config.vim index 7bcf647..0e6b28c 100644 --- a/autoload/vundle/config.vim +++ b/autoload/vundle/config.vim @@ -1,11 +1,19 @@ func! vundle#config#bundle(arg, ...) let bundle = vundle#config#init_bundle(a:arg, a:000) - call s:rtp_rm_a() - call add(g:bundles, bundle) - call s:rtp_add_a() + if exists('g:vundle_lazy_load') && g:vundle_lazy_load + call add(g:bundles, bundle) + else + call s:rtp_rm_a() + call add(g:bundles, bundle) + call s:rtp_add_a() + endif return bundle endf +func! vundle#config#activate_bundles() + call s:rtp_add_a() +endf + func! vundle#config#init() if !exists('g:bundles') | let g:bundles = [] | endif call s:rtp_rm_a()