From b6c008246c2551ff4fd7fb23a470896d690c0f60 Mon Sep 17 00:00:00 2001 From: Shahaf Arad Date: Fri, 20 Mar 2015 23:26:28 +0200 Subject: [PATCH] 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. --- autoload/vundle.vim | 26 ++++++++++++++++++++++++++ autoload/vundle/config.vim | 7 +++++++ autoload/vundle/installer.vim | 7 +++++++ autoload/vundle/scripts.vim | 7 +++++++ 4 files changed, 47 insertions(+) diff --git a/autoload/vundle.vim b/autoload/vundle.vim index e458618e..9451cd11 100644 --- a/autoload/vundle.vim +++ b/autoload/vundle.vim @@ -4,6 +4,9 @@ " Readme: http://github.com/gmarik/Vundle.vim/blob/master/README.md " Version: 0.10.2 +" Save the path from which Vundle was first loaded +let vundle#vundle_path = expand(':p:h:h') + " Plugin Commands com! -nargs=+ -bar Plugin \ call vundle#config#bundle() @@ -64,6 +67,21 @@ func! vundle#rc(...) abort if a:0 > 0 let g:vundle#bundle_dir = expand(a:1, 1) endif + + " If this function has already been called and Vim hasn't finished loading, + " that is, we are not sourcing our .vimrc file later on, Vundle is probably + " loading from several sources which can lead to unpredictable results. + if exists('g:vundle#vundle_loading') && g:vundle#vundle_loading + echoerr 'Vundle is probably loading from several sources. ' . + \ 'This can lead to unpredictable results! ' . + \ 'Please find and remove the duplication.' + endif + + " Set g:vundle_loading only if Vim hasn't finished loading. + if !exists('g:vundle#vundle_loaded') || !g:vundle#vundle_loaded + let g:vundle#vundle_loading = 1 + endif + call vundle#config#init() endf @@ -87,4 +105,12 @@ let vundle#lazy_load = 0 let vundle#log = [] let vundle#updated_bundles = [] +augroup vundle + au! + + " Tell Vundle it has finished loading and Vim is up and running. + au VimEnter * unlet g:vundle#vundle_loading + au VimEnter * let g:vundle#vundle_loaded = 1 +augroup END + " vim: set expandtab sts=2 ts=2 sw=2 tw=78 norl: diff --git a/autoload/vundle/config.vim b/autoload/vundle/config.vim index 0e02b112..2a1aefd4 100644 --- a/autoload/vundle/config.vim +++ b/autoload/vundle/config.vim @@ -1,3 +1,10 @@ +" Verify this file is sourced from the correct Vundle path +if expand(':p:h:h:h') !=# vundle#vundle_path + echoerr 'Vundle is probably loading from several sources. ' . + \ 'This can lead to unpredictable results! ' . + \ 'Please find and remove the duplication.' +endif + " --------------------------------------------------------------------------- " Add a plugin to the runtimepath. " diff --git a/autoload/vundle/installer.vim b/autoload/vundle/installer.vim index 472271a3..e3513956 100644 --- a/autoload/vundle/installer.vim +++ b/autoload/vundle/installer.vim @@ -1,3 +1,10 @@ +" Verify this file is sourced from the correct Vundle path +if expand(':p:h:h:h') !=# vundle#vundle_path + echoerr 'Vundle is probably loading from several sources. ' . + \ 'This can lead to unpredictable results! ' . + \ 'Please find and remove the duplication.' +endif + " --------------------------------------------------------------------------- " Try to clone all new bundles given (or all bundles in g:vundle#bundles by " default) to g:vundle#bundle_dir. If a:bang is 1 it will also update all diff --git a/autoload/vundle/scripts.vim b/autoload/vundle/scripts.vim index 5d564760..0d356924 100644 --- a/autoload/vundle/scripts.vim +++ b/autoload/vundle/scripts.vim @@ -1,3 +1,10 @@ +" Verify this file is sourced from the correct Vundle path +if expand(':p:h:h:h') !=# vundle#vundle_path + echoerr 'Vundle is probably loading from several sources. ' . + \ 'This can lead to unpredictable results! ' . + \ 'Please find and remove the duplication.' +endif + " --------------------------------------------------------------------------- " Search the database from vim-script.org for a matching plugin. If no " argument is given, list all plugins. This function is used by the :Plugins