Browse Source

Manually bind and load scripts via BundleBind! with tags

pull/98/head
Rainux Luo 14 years ago
parent
commit
c6faf362a3
4 changed files with 65 additions and 6 deletions
  1. +5
    -0
      README.md
  2. +2
    -2
      autoload/vundle.vim
  3. +27
    -4
      autoload/vundle/config.vim
  4. +31
    -0
      doc/vundle.txt

+ 5
- 0
README.md View File

@ -41,6 +41,11 @@
Bundle 'git://git.wincent.com/command-t.git' 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! filetype plugin indent on " required!
" "
" Brief help " Brief help


+ 2
- 2
autoload/vundle.vim View File

@ -7,8 +7,8 @@
com! -nargs=+ Bundle com! -nargs=+ Bundle
\ call vundle#config#bundle(<args>) \ call vundle#config#bundle(<args>)
com! -nargs=0 -bang BundleBind
\ call vundle#config#bind()
com! -nargs=* -bang BundleBind
\ call vundle#config#bind(<f-args>)
com! -nargs=? -bang -complete=custom,vundle#scripts#complete BundleInstall com! -nargs=? -bang -complete=custom,vundle#scripts#complete BundleInstall
\ call vundle#installer#new('!' == '<bang>', <q-args>) \ call vundle#installer#new('!' == '<bang>', <q-args>)


+ 27
- 4
autoload/vundle/config.vim View File

@ -3,10 +3,16 @@ func! vundle#config#bundle(arg, ...)
call add(g:bundles, bundle) call add(g:bundles, bundle)
endf endf
func! vundle#config#bind()
call s:rtp_rm(g:bundles)
let bind_bundles = filter(copy(g:bundles), 'v:val.bind')
call vundle#config#require(bind_bundles)
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 endf
func! vundle#config#init() func! vundle#config#init()
@ -79,6 +85,23 @@ func! s:rtp_add(bundles) abort
endfor endfor
endf 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
return is_matched
endf
func! s:expand_path(path) abort func! s:expand_path(path) abort
return simplify(expand(a:path)) return simplify(expand(a:path))
endf endf


+ 31
- 0
doc/vundle.txt View File

@ -74,6 +74,12 @@ in order to install/search [all available vim scripts]
Bundle 'git://git.wincent.com/command-t.git' 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! filetype plugin indent on " required!
" or " or
" filetype plugin on " to not use the indentation settings set by plugins " filetype plugin on " to not use the indentation settings set by plugins
@ -108,6 +114,23 @@ equals full uri >
NOTE: Vundle defaults to http:// protocol for the short URIs 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!* *BundleBind!*
`Bundle` command just tell Vundle which scripts you want to use, it doesn't `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. tell Vim load them, i.e, it doesn't update the 'runtimepath' option of Vim.
@ -119,6 +142,14 @@ 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 Vim startup much faster while keeping 'runtimepath' ordered according to the
bundles declarations. 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 ~ 4.2 INSTALL SCRIPTS ~
*vundle-scripts-install* *BundleInstall* *vundle-scripts-install* *BundleInstall*


Loading…
Cancel
Save