diff --git a/README.md b/README.md index 95c5ec0..fcfd2ce 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -## [Help Maintain Vundle](https://github.com/gmarik/Vundle.vim/issues/241) +## [Help Maintain Vundle](https://github.com/gmarik/Vundle.vim/issues/383) ## About @@ -29,7 +29,8 @@ Installation requires [Git] and triggers [`git clone`] for each configured repository to `~/.vim/bundle/` by default. Curl is required for search. - If you are using Windows, go directly to [Windows setup]. If you run into any issues, please consult the [FAQ]. + If you are using Windows, go directly to [Windows setup]. If you run into any issues, please consult the [FAQ]. Also, + see the [Tips] wiki page for some additional options. 2. Set up [Vundle]: @@ -45,32 +46,31 @@ " set the runtime path to include Vundle and initialize set rtp+=~/.vim/bundle/vundle/ - call vundle#rc() - " alternatively, pass a path where Vundle should install plugins - "let path = '~/some/path/here' - "call vundle#rc(path) + call vundle#begin() + " alternatively, pass where Vundle should install plugins + "call vundle#begin('~/some/plugin/directory') " let Vundle manage Vundle, required Plugin 'gmarik/vundle' " The following are examples of different formats supported. - " Keep Plugin commands between here and filetype plugin indent on. - " scripts on GitHub repos - Plugin 'tpope/vim-fugitive' - Plugin 'Lokaltog/vim-easymotion' - Plugin 'tpope/vim-rails.git' - " The sparkup vim script is in a subdirectory of this repo called vim. - " Pass the path to set the runtimepath properly. - Plugin 'rstacruz/sparkup', {'rtp': 'vim/'} - " scripts from http://vim-scripts.org/vim/scripts.html + " plugins on GitHub repos + Plugin 'tpope/vim-fugitive' "A plugin for git integration + " plugins from http://vim-scripts.org/vim/scripts.html Plugin 'L9' - Plugin 'FuzzyFinder' - " scripts not on GitHub + " plugins not on GitHub Plugin 'git://git.wincent.com/command-t.git' " git repos on your local machine (i.e. when working on your own plugin) Plugin 'file:///home/gmarik/path/to/plugin' - " ... + " The sparkup vim script is in a subdirectory of this repo called vim. + " Pass the path to set the runtimepath properly. + Plugin 'rstacruz/sparkup', {'rtp': 'vim/'} + " Plugin will clone to the folder 'finder' inside `~/.vim/bundle`. + " Use to avoid plugin name collisions. + Plugin 'FuzzyFinder', {'name': 'finder'} + " Plugins available after vundle#end() finishes. + call vundle#end() filetype plugin indent on " required " To ignore plugin indent changes, instead use: "filetype plugin on @@ -82,7 +82,6 @@ " :PluginClean(!) - confirm (or auto-approve) removal of unused plugins " " see :h vundle for more details or wiki for FAQ - " NOTE: comments after Plugin commands are not allowed. " Put your stuff after this line ``` @@ -135,6 +134,7 @@ see [Vundle contributors](https://github.com/gmarik/vundle/graphs/contributors) [Vundle]:http://github.com/gmarik/vundle [Windows setup]:https://github.com/gmarik/vundle/wiki/Vundle-for-Windows [FAQ]:https://github.com/gmarik/vundle/wiki +[Tips]:https://github.com/gmarik/Vundle.vim/wiki/Tips-and-Tricks [Vim]:http://www.vim.org [Git]:http://git-scm.com [`git clone`]:http://gitref.org/creating/#clone diff --git a/autoload/vundle.vim b/autoload/vundle.vim index 76d4d59..0b800a1 100644 --- a/autoload/vundle.vim +++ b/autoload/vundle.vim @@ -6,7 +6,7 @@ " Plugin Commands com! -nargs=+ -bar Plugin -\ call vundle#config#bundle() +\ call vundle#config#bundle_lazy() com! -nargs=? -bang -complete=custom,vundle#scripts#complete PluginInstall \ call vundle#installer#new('!' == '', ) @@ -56,11 +56,24 @@ sign define Vu_deleted text=- texthl=Comment sign define Vu_helptags text=* texthl=Comment endif +func! vundle#begin(...) abort + let g:bundle_dir = len(a:000) > 0 ? expand(a:1, 1) : expand('$HOME/.vim/bundle', 1) + let g:bundles = [] + let g:updated_bundles = [] + let g:vundle_log = [] + let g:vundle_changelog = ['Updated Plugins:'] + com! -nargs=+ -bar Plugin call vundle#config#bundle_lazy() +endf + +func! vundle#end(...) abort + call vundle#config#activate_all_plugins() + com! -nargs=+ -bar Plugin call vundle#config#bundle() +endf func! vundle#rc(...) abort let g:bundle_dir = len(a:000) > 0 ? expand(a:1, 1) : expand('$HOME/.vim/bundle', 1) + let g:bundles = [] let g:updated_bundles = [] let g:vundle_log = [] let g:vundle_changelog = ['Updated Plugins:'] - call vundle#config#init() endf diff --git a/autoload/vundle/config.vim b/autoload/vundle/config.vim index 7bcf647..1f6b0fc 100644 --- a/autoload/vundle/config.vim +++ b/autoload/vundle/config.vim @@ -3,13 +3,18 @@ func! vundle#config#bundle(arg, ...) call s:rtp_rm_a() call add(g:bundles, bundle) call s:rtp_add_a() + call s:rtp_add_defaults() return bundle endf -func! vundle#config#init() - if !exists('g:bundles') | let g:bundles = [] | endif - call s:rtp_rm_a() - let g:bundles = [] +func! vundle#config#bundle_lazy(arg, ...) + call add(s:lazy_bundles, [a:arg, a:000]) +endf + +func! vundle#config#activate_all_plugins() + call extend(g:bundles, map(s:lazy_bundles, 'vundle#config#init_bundle(v:val[0], v:val[1])')) + call s:rtp_add_a() + call s:rtp_add_defaults() endf func! vundle#config#require(bundles) abort @@ -21,6 +26,7 @@ func! vundle#config#require(bundles) abort exec 'runtime! '.b.name.'/after/*.vim' call s:rtp_rm(g:bundle_dir) endfor + call s:rtp_add_defaults() endf func! vundle#config#init_bundle(name, opts) @@ -67,6 +73,21 @@ func! s:parse_name(arg) return {'name': name, 'uri': uri, 'name_spec': arg } endf +func! s:rtp_add_defaults() + let current = &rtp + set rtp&vim + let default = &rtp + let &rtp = current + for item in reverse(split(default, ',')) + exec 'set rtp-=' . item + if item =~ 'after$' + exec 'set rtp+=' . item + else + exec 'set rtp^=' . item + endif + endfor +endf + func! s:rtp_rm_a() let paths = map(copy(g:bundles), 'v:val.rtpath') let prepends = join(paths, ',') @@ -102,6 +123,7 @@ func! s:rtpath(opts) endf let s:bundle = {} +let s:lazy_bundles = [] func! s:bundle.path() return s:expand_path(g:bundle_dir.'/'.self.name) diff --git a/doc/vundle.txt b/doc/vundle.txt index 5d397e0..ac67e45 100644 --- a/doc/vundle.txt +++ b/doc/vundle.txt @@ -69,41 +69,48 @@ more information. Put this at the top of your `.vimrc` to use Vundle. Remove bundles you don't need, they are for illustration purposes. > - set nocompatible " be iMproved, required - filetype off " required - - " set the runtime path to include Vundle and initialize - set rtp+=~/.vim/bundle/vundle/ - call vundle#rc() - " alternatively, pass a path where Vundle should install bundles - "let path = '~/some/path/here' - "call vundle#rc(path) - - " let Vundle manage Vundle, required - Plugin 'gmarik/vundle' - - " The following are examples of different formats supported. - " Keep bundle commands between here and filetype plugin indent on. - " plugins on GitHub repos - Plugin 'tpope/vim-fugitive' - Plugin 'Lokaltog/vim-easymotion' - Plugin 'tpope/vim-rails.git' - " The sparkup vim script is in a subdirectory of this repo called vim. - " Pass the path to set the runtimepath properly. - Plugin 'rstacruz/sparkup', {'rtp': 'vim/'} - " plugins from http://vim-scripts.org/vim/scripts.html - Plugin 'L9' - Plugin 'FuzzyFinder' - " plugins not on GitHub - Plugin 'git://git.wincent.com/command-t.git' - " git repos on your local machine (i.e. when working on your own plugin) - Plugin 'file:///home/gmarik/path/to/plugin' - " ... - - filetype plugin indent on " required - " To ignore plugin indent changes, instead use: - "filetype plugin on - " Put your stuff after this line + set nocompatible " be iMproved, required + filetype off " required + + " set the runtime path to include Vundle and initialize + set rtp+=~/.vim/bundle/vundle/ + call vundle#begin() + " alternatively, pass where Vundle should install plugins + "call vundle#begin('~/some/plugin/directory') + + " let Vundle manage Vundle, required + Plugin 'gmarik/vundle' + + " The following are examples of different formats supported. + " plugins on GitHub repos + Plugin 'tpope/vim-fugitive' "A plugin for git integration + " plugins from http://vim-scripts.org/vim/scripts.html + Plugin 'L9' + " plugins not on GitHub + Plugin 'git://git.wincent.com/command-t.git' + " git repos on your local machine (i.e. when working on your own plugin) + Plugin 'file:///home/gmarik/path/to/plugin' + " The sparkup vim script is in a subdirectory of this repo called vim. + " Pass the path to set the runtimepath properly. + Plugin 'rstacruz/sparkup', {'rtp': 'vim/'} + " Plugin will clone to the folder 'finder' inside ~/.vim/bundle. + " Use to avoid plugin name collisions. + Plugin 'FuzzyFinder', {'name': 'finder'} + + " Plugins available after vundle#end() finishes. + call vundle#end() + filetype plugin indent on " required + " To ignore plugin indent changes, instead use: + "filetype plugin on + " + " Brief help + " :PluginList - list configured plugins + " :PluginInstall(!) - install (update) plugins + " :PluginSearch(!) foo - search (or refresh cache first) for foo + " :PluginClean(!) - confirm (or auto-approve) removal of unused plugins + " + " see :h vundle for more details or wiki for FAQ + " Put your stuff after this line 4. Install configured bundles: diff --git a/test/vimrc b/test/vimrc index 13dd2e2..1c613e9 100644 --- a/test/vimrc +++ b/test/vimrc @@ -1,10 +1,10 @@ " vim -u test/vimrc set nocompatible - set nowrap +filetype off +syntax on let bundle_dir = '/tmp/vundle-test/bundles/' -" let src = 'http://github.com/gmarik/vundle.git' " Vundle Options " let g:vundle_default_git_proto = 'git' @@ -12,16 +12,11 @@ let bundle_dir = '/tmp/vundle-test/bundles/' silent execute '!mkdir -p '.bundle_dir silent execute '!ln -f -s ~/.vim/bundle/vundle '.bundle_dir -filetype off -syntax on - runtime macros/matchit.vim " This test should be executed in "test" directory exec 'set rtp^='.bundle_dir.'vundle/' - -call vundle#rc(bundle_dir) - +call vundle#begin(bundle_dir) Plugin 'molokai' " vim-scripts name @@ -58,6 +53,7 @@ Bundle 'vim-scripts/RubySinatra' " syntax issue #203 Bundle 'jimenezrick/vimerl' +call vundle#end() filetype plugin indent on " Automatically detect file types. set wildignore+=doc " should not break helptags