Skip to content

Commit 5af0260

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 5af0260

File tree

4 files changed

+46
-0
lines changed

4 files changed

+46
-0
lines changed

autoload/vundle.vim

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
" Readme: http://github.com/gmarik/Vundle.vim/blob/master/README.md
55
" Version: 0.10.2
66

7+
" Save the path from which Vundle was first loaded
8+
let g:vundle_path = expand('<sfile>:p:h:h')
9+
710
" Plugin Commands
811
com! -nargs=+ -bar Plugin
912
\ call vundle#config#bundle(<args>)
@@ -61,6 +64,20 @@ endif
6164
" :Plugin command in the vimrc. It is not possible to do this automatically
6265
" because when loading the vimrc file no plugins where loaded yet.
6366
func! vundle#rc(...) abort
67+
" If this function has already been called and Vim hasn't finished loading,
68+
" that is, we are not sourcing our .vimrc file later on, Vundle is probably
69+
" loading from several sources which can lead to unpredictable results.
70+
if exists('g:vundle_loading') && g:vundle_loading
71+
echoerr 'Vundle is probably loading from several sources. ' .
72+
\ 'This can lead to unpredictable results! ' .
73+
\ 'Please find and remove the duplication.'
74+
endif
75+
76+
" Set g:vundle_loading only if Vim hasn't finished loading.
77+
if !exists('g:vundle_loaded') || !g:vundle_loaded
78+
let g:vundle_loading = 1
79+
endif
80+
6481
let g:bundle_dir = len(a:000) > 0 ? expand(a:1, 1) : expand('$HOME/.vim/bundle', 1)
6582
let g:updated_bundles = []
6683
let g:vundle_log = []
@@ -81,4 +98,12 @@ func! vundle#end(...) abort
8198
call vundle#config#activate_bundles()
8299
endf
83100

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

autoload/vundle/config.vim

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
" Verify this file is sourced from the correct Vundle path
2+
if expand('<sfile>:p:h:h:h') !=# g:vundle_path
3+
echoerr 'Vundle is probably loading from several sources. ' .
4+
\ 'This can lead to unpredictable results! ' .
5+
\ 'Please find and remove the duplication.'
6+
endif
7+
18
" ---------------------------------------------------------------------------
29
" Add a plugin to the runtimepath.
310
"

autoload/vundle/installer.vim

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
" Verify this file is sourced from the correct Vundle path
2+
if expand('<sfile>:p:h:h:h') !=# g:vundle_path
3+
echoerr 'Vundle is probably loading from several sources. ' .
4+
\ 'This can lead to unpredictable results! ' .
5+
\ 'Please find and remove the duplication.'
6+
endif
7+
18
" ---------------------------------------------------------------------------
29
" Try to clone all new bundles given (or all bundles in g:bundles by default)
310
" to g:bundle_dir. If a:bang is 1 it will also update all plugins (git pull).

autoload/vundle/scripts.vim

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
" Verify this file is sourced from the correct Vundle path
2+
if expand('<sfile>:p:h:h:h') !=# g:vundle_path
3+
echoerr 'Vundle is probably loading from several sources. ' .
4+
\ 'This can lead to unpredictable results! ' .
5+
\ 'Please find and remove the duplication.'
6+
endif
7+
18
" ---------------------------------------------------------------------------
29
" Search the database from vim-script.org for a matching plugin. If no
310
" argument is given, list all plugins. This function is used by the :Plugins

0 commit comments

Comments
 (0)