diff --git a/README.md b/README.md index 9dbd744..856b953 100644 --- a/README.md +++ b/README.md @@ -8,60 +8,65 @@ 1. Setup [Vundle]: - ``` - $ git clone http://github.com/gmarik/vundle.git ~/.vim/bundle/vundle - ``` + ``` + $ git clone http://github.com/gmarik/vundle.git ~/.vim/bundle/vundle + ``` 2. Configure bundles: - Sample `.vimrc`: - - ```vim - set nocompatible " be iMproved - filetype off " required! - - set rtp+=~/.vim/bundle/vundle/ - call vundle#rc() - - " let Vundle manage Vundle - " required! - Bundle 'gmarik/vundle' - - " My Bundles here: - " - " original repos on github - Bundle 'tpope/vim-fugitive' - Bundle 'Lokaltog/vim-easymotion' - Bundle 'rstacruz/sparkup', {'rtp': 'vim/'} - " vim-scripts repos - Bundle 'L9' - Bundle 'FuzzyFinder' - Bundle 'rails.vim' - " non github repos - Bundle 'git://git.wincent.com/command-t.git' - " ... - - filetype plugin indent on " required! - " - " Brief help - " :BundleList - list configured bundles - " :BundleInstall(!) - install(update) bundles - " :BundleSearch(!) foo - search(or refresh cache first) for foo - " :BundleClean(!) - confirm(or auto-approve) removal of unused bundles - " - " see :h vundle for more details or wiki for FAQ - " NOTE: comments after Bundle command are not allowed.. - - ``` + Sample `.vimrc`: + + ```vim + set nocompatible " be iMproved + filetype off " required! + + set rtp+=~/.vim/bundle/vundle/ + call vundle#rc() + + " let Vundle manage Vundle + " required! + Bundle 'gmarik/vundle' + + " My Bundles here: + " + " original repos on github + Bundle 'tpope/vim-fugitive' + Bundle 'Lokaltog/vim-easymotion' + Bundle 'rstacruz/sparkup', {'rtp': 'vim/'} + " vim-scripts repos + Bundle 'L9' + Bundle 'FuzzyFinder' + Bundle 'rails.vim' + " non github repos + Bundle 'git://git.wincent.com/command-t.git' + " ... + + " Slow scripts which will not be bound and loaded at Vim startup. + " When needed, you can manually bind them via `BundleBind!` command, + " run `:help Bundle-option-bind` and `:help BundleBind!` for more details. + Bundle 'c.vim', {'bind': 0, 'tags': ['c']} + + filetype plugin indent on " required! + " + " Brief help + " :BundleList - list configured bundles + " :BundleInstall(!) - install(update) bundles + " :BundleSearch(!) foo - search(or refresh cache first) for foo + " :BundleClean(!) - confirm(or auto-approve) removal of unused bundles + " + " see :h vundle for more details or wiki for FAQ + " NOTE: comments after Bundle command are not allowed.. + + ``` 3. Install configured bundles: - Launch `vim`, run `:BundleInstall`. + Launch `vim`, run `:BundleInstall`. *Windows users* see [Vundle for Windows](https://github.com/gmarik/vundle/wiki/Vundle-for-Windows) Installing requires [Git] and triggers [Git clone](http://gitref.org/creating/#clone) for each configured repo to `~/.vim/bundle/`. - + 4. Consider donating [![](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=T44EJZX8RBUWY) @@ -74,7 +79,7 @@ [Vundle] allows to: - keep track and configure your scripts right in `.vimrc` -- [install] configured scripts (aka bundle) +- [install] configured scripts (aka bundle) - [update] configured scripts - [search] by name [all available vim scripts] - [clean] unused scripts up diff --git a/autoload/vundle.vim b/autoload/vundle.vim index 632a5b2..ca44829 100644 --- a/autoload/vundle.vim +++ b/autoload/vundle.vim @@ -7,6 +7,9 @@ com! -nargs=+ Bundle \ call vundle#config#bundle() +com! -nargs=* -bang BundleBind +\ call vundle#config#bind() + com! -nargs=? -bang -complete=custom,vundle#scripts#complete BundleInstall \ call vundle#installer#new('!' == '', ) diff --git a/autoload/vundle/config.vim b/autoload/vundle/config.vim index e8443c1..1831d2f 100644 --- a/autoload/vundle/config.vim +++ b/autoload/vundle/config.vim @@ -1,30 +1,41 @@ 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() +endf + +func! vundle#config#bind(...) + if a:0 == 0 + call s:rtp_rm(g:bundles) + let bind_bundles = filter(copy(g:bundles), 'v:val.bind') + call vundle#config#require(bind_bundles) + else + let matched_bundles = filter(copy(g:bundles), + \ 's:is_tags_matched(v:val, '.string(a:000).')') + call vundle#config#require(matched_bundles) + end endf func! vundle#config#init() - if !exists('g:bundles') | let g:bundles = [] | endif - call s:rtp_rm_a() + if exists('g:bundles') + call s:rtp_rm(g:bundles) + endif let g:bundles = [] endf func! vundle#config#require(bundles) abort - for b in a:bundles - call s:rtp_add(b.rtpath()) - call s:rtp_add(g:bundle_dir) - " TODO: it has to be relative rtpath, not bundle.name - exec 'runtime! '.b.name.'/plugin/*.vim' - exec 'runtime! '.b.name.'/after/*.vim' - call s:rtp_rm(g:bundle_dir) - endfor + call s:rtp_add(a:bundles) + " It's OK to do this since every plugin prevent itself be loaded twice + runtime! plugin/*.vim + runtime! after/*.vim endf func! vundle#config#init_bundle(name, opts) let opts = extend(s:parse_options(a:opts), s:parse_name(substitute(a:name,"['".'"]\+','','g'))) - return extend(opts, copy(s:bundle)) + let bundle = extend(copy(s:bundle), opts) + + let bundle.escaped_rtpath = fnameescape(expand(bundle.rtpath())) + let bundle.escaped_rtpath_after = fnameescape(expand(bundle.rtpath().'/after')) + return bundle endf func! s:parse_options(opts) @@ -60,29 +71,42 @@ func! s:parse_name(arg) return {'name': name, 'uri': uri, 'name_spec': arg } endf -func! s:rtp_rm_a() - call filter(copy(g:bundles), 's:rtp_rm(v:val.rtpath())') +func! s:rtp_rm(bundles) abort + for bundle in a:bundles + exec 'set rtp-='.bundle.escaped_rtpath + exec 'set rtp-='.bundle.escaped_rtpath_after + endfor endf -func! s:rtp_add_a() - call filter(reverse(copy(g:bundles)), 's:rtp_add(v:val.rtpath())') +func! s:rtp_add(bundles) abort + for bundle in reverse(copy(a:bundles)) + exec 'set rtp^='.bundle.escaped_rtpath + exec 'set rtp+='.bundle.escaped_rtpath_after + endfor endf -func! s:rtp_rm(dir) abort - exec 'set rtp-='.fnameescape(expand(a:dir)) - exec 'set rtp-='.fnameescape(expand(a:dir.'/after')) -endf +func! s:is_tags_matched(bundle, tags) + if !has_key(a:bundle, 'tags') + return 0 + endif + + let is_matched = 0 + for tag in a:bundle.tags + let is_matched = index(a:tags, tag) != -1 + + if is_matched + break + endif + endfor -func! s:rtp_add(dir) abort - exec 'set rtp^='.fnameescape(expand(a:dir)) - exec 'set rtp+='.fnameescape(expand(a:dir.'/after')) + return is_matched endf func! s:expand_path(path) abort return simplify(expand(a:path)) endf -let s:bundle = {} +let s:bundle = {'bind': 1} func! s:bundle.path() return s:expand_path(g:bundle_dir.'/'.self.name) diff --git a/doc/vundle.txt b/doc/vundle.txt index 3b347ce..8e2c6ee 100644 --- a/doc/vundle.txt +++ b/doc/vundle.txt @@ -28,7 +28,7 @@ Vundle is a short cut for Vim bundle and is the Vim plug-in manager. Vundle allows to: - keep track and configure your scripts right in `.vimrc` -- install configured scripts (aka bundle) +- install configured scripts (aka bundle) - update configured scripts - search [all available vim scripts] by name - clean up from unused scripts @@ -38,7 +38,7 @@ Also *Vundle* : - manages runtime path of your installed scripts - regenerates helptags automatically -Vundle takes advantage of [vim-scripts.org](http://vim-scripts.org) +Vundle takes advantage of [vim-scripts.org](http://vim-scripts.org) in order to install/search [all available vim scripts] 3. QUICK START ~ @@ -51,32 +51,38 @@ in order to install/search [all available vim scripts] Sample `.vimrc`: > - set nocompatible " be iMproved - filetype off " required! - - set rtp+=~/.vim/vundle.git/ - call vundle#rc() - - " let Vundle manage Vundle - Bundle 'gmarik/vundle' - - " My Bundles here: - " - " original repos on github - Bundle 'tpope/vim-fugitive' - Bundle 'Lokaltog/vim-easymotion' - Bundle 'rstacruz/sparkup', {'rtp': 'vim/'} - " vim-scripts repos - Bundle 'L9' - Bundle 'FuzzyFinder' - Bundle 'rails.vim' - " non github repos - Bundle 'git://git.wincent.com/command-t.git' - " ... - - filetype plugin indent on " required! - " or - " filetype plugin on " to not use the indentation settings set by plugins + set nocompatible " be iMproved + filetype off " required! + + set rtp+=~/.vim/vundle.git/ + call vundle#rc() + + " let Vundle manage Vundle + Bundle 'gmarik/vundle' + + " My Bundles here: + " + " original repos on github + Bundle 'tpope/vim-fugitive' + Bundle 'Lokaltog/vim-easymotion' + Bundle 'rstacruz/sparkup', {'rtp': 'vim/'} + " vim-scripts repos + Bundle 'L9' + Bundle 'FuzzyFinder' + Bundle 'rails.vim' + " non github repos + Bundle 'git://git.wincent.com/command-t.git' + " ... + + " Slow scripts which will not be bound and loaded at Vim startup. + " When needed, you can manually bind them via `BundleBind!` command, + " run `:help |Bundle-option-bind|` and `:help |BundleBind!|` for more + " details. + Bundle 'c.vim', {'bind': 0, 'tags': ['c']} + + filetype plugin indent on " required! + " or + " filetype plugin on " to not use the indentation settings set by plugins 3) Install configured bundles: @@ -84,7 +90,7 @@ in order to install/search [all available vim scripts] :BundleInstall -Installing requires [Git] and triggers [Git clone](http://gitref.org/creating/#clone) for +Installing requires [Git] and triggers [Git clone](http://gitref.org/creating/#clone) for each configured repo to `~/.vim/bundle/`. 4. SCRIPTS ~ @@ -94,7 +100,7 @@ each configured repo to `~/.vim/bundle/`. Before installing scripts they need to be configured. It's done using `Bundle` command in `.vimrc`: > - Bundle 'git_repo_uri' " 'git_repo_uri' should be a valid uri to git repository + Bundle 'git_repo_uri' " 'git_repo_uri' should be a valid uri to git repository or > Bundle 'script_name' " 'script-name' should be an official script name (see |vundle-scripts-search| ) @@ -108,6 +114,42 @@ equals full uri > NOTE: Vundle defaults to http:// protocol for the short URIs + *Bundle-option-bind* +If some of your scripts will slow down your Vim startup, and you don't really +often need them, you have an option to disable bind them at Vim startup: > + + Bundle 'c.vim', {'bind': 0} + +When you need, these scripts can be bound manually via |BundleBind!| command. + + *Bundle-option-tags* +Scripts can be grouped via tags option: > + + Bundle 'c.vim', {'tags', ['c', 'slow']} + Bundle 'bash-support.vim', {'tags', ['bash', 'slow']} + +Currently the only usage of tags is to allow you manually bind slow scripts +when needed, but group scripts by tags should be useful in the future. + + *BundleBind!* +`Bundle` command just tell Vundle which scripts you want to use, it doesn't +tell Vim load them, i.e, it doesn't update the 'runtimepath' option of Vim. + +To tell Vim load your scripts, `BundleBind!` must be executed. But Vundle will +do it automatically, so usually you don't need to do it yourself. + +The benefit of use an extra command to update 'runtimepath' is, we can make +Vim startup much faster while keeping 'runtimepath' ordered according to the +bundles declarations. + +You can run `BundleBind!` manually to bind and load those scripts which +haven't get bound and loaded at Vim startup: > + + :BundleBind! slow + +`BundleBind!` can accept any number of tags, just use space to separate them: +> + :BundleBind! c bash ruby javascript 4.2 INSTALL SCRIPTS ~ *vundle-scripts-install* *BundleInstall* @@ -122,7 +164,7 @@ BundleInstall allows to install scripts by name:> :BundleInstall unite.vim installs and activates unite.vim. You can use Tab to auto-complete known script names. -NOTE: installation, as just described, doesn't automatically configure scripts; +NOTE: installation, as just described, doesn't automatically configure scripts; you have to configure them manually. 4.3 UPDATE SCRIPTS ~ @@ -170,11 +212,11 @@ run > :BundleClean -requires confirmation before removal of unused script-dirs from your `.vim/bundle`. +requires confirmation before removal of unused script-dirs from your `.vim/bundle`. *BundleClean!* > - :BundleClean! + :BundleClean! removes unused scripts with no questions. @@ -201,8 +243,8 @@ content: > Bundle 'unite-colorscheme' As the first line(starting with `"Keymap:`) shows, certain actions may be applied -to selected bundles . Move cursor over line `Bundle 'unite.vim'` and press i -key(install, see |vundle-keymappings| for more details). +to selected bundles . Move cursor over line `Bundle 'unite.vim'` and press i +key(install, see |vundle-keymappings| for more details). After unite.vim is installed - `:Unite file` command should be available to prove 'unite.vim' availability. diff --git a/plugin/vundle.vim b/plugin/vundle.vim new file mode 100644 index 0000000..dc19532 --- /dev/null +++ b/plugin/vundle.vim @@ -0,0 +1,7 @@ +if exists('g:loaded_vundle') || &cp + finish +endif +let g:loaded_vundle = 1 + +" Bind and load all scripts bundles immediately. +BundleBind!