Skip to content

Commit a321861

Browse files
author
Shahaf Arad
committed
Error when Vundle is loading from multiple sources.
It's quite common to see issues related to Vundle accidentally loading from several sources. Try to mitigate this issue by echoing an error.
1 parent 7d9b108 commit a321861

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

autoload/vundle.vim

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,20 @@ endif
6161
" :Plugin command in the vimrc. It is not possible to do this automatically
6262
" because when loading the vimrc file no plugins where loaded yet.
6363
func! vundle#rc(...) abort
64+
" If this function has already been called and Vim hasn't finished loading,
65+
" that is, we are not sourcing our .vimrc file later on, Vundle is probably
66+
" loading from several sources which can lead to unpredictable results.
67+
if exists('g:vundle_loading') && g:vundle_loading
68+
echoerr 'Vundle is probably loading from several sources. ' .
69+
\ 'This can lead to unpredictable results! ' .
70+
\ 'Please find and remove the duplication.'
71+
endif
72+
73+
" Set g:vundle_loading only if Vim hasn't finished loading.
74+
if !exists('g:vundle_loaded') || !g:vundle_loaded
75+
let g:vundle_loading = 1
76+
endif
77+
6478
let g:bundle_dir = len(a:000) > 0 ? expand(a:1, 1) : expand('$HOME/.vim/bundle', 1)
6579
let g:updated_bundles = []
6680
let g:vundle_log = []
@@ -81,4 +95,12 @@ func! vundle#end(...) abort
8195
call vundle#config#activate_bundles()
8296
endf
8397

98+
augroup vundle
99+
au!
100+
101+
" Tell Vundle it has finished loading and Vim is up and running.
102+
au VimEnter * unlet g:vundle_loading
103+
au VimEnter * let g:vundle_loaded = 1
104+
augroup END
105+
84106
" vim: set expandtab sts=2 ts=2 sw=2 tw=78 norl:

0 commit comments

Comments
 (0)