Browse Source

add localbundle and it's vimrc sample

pull/179/head
Rykka 14 years ago
parent
commit
7d68d686bb
6 changed files with 175 additions and 3 deletions
  1. +43
    -0
      README.md
  2. +4
    -0
      autoload/vundle.vim
  3. +3
    -3
      autoload/vundle/config.vim
  4. +65
    -0
      autoload/vundle/installer.vim
  5. +53
    -0
      autoload/vundle/local.vim
  6. +7
    -0
      autoload/vundle/scripts.vim

+ 43
- 0
README.md View File

@ -53,6 +53,49 @@
" NOTE: comments after Bundle command are not allowed..
```
Sample `.vimrc` For the using of `localbundle`
```vim
" only load once
if !exists("g:vimrc_bundle_loaded")
set nocompatible
syntax on
filetype off
" set it to 1 then vundle will only adding the localbundle dir to &rtp.
let g:vundle_local = 1
" set the default localbundle directory
let g:bundle_local_dir = '~/.vim/localbundle'
if filereadable(expand(g:bundle_local_dir)."/autoload/vundle.vim")
exe 'set rtp^='.g:bundle_local_dir
exe 'set rtp+='.g:bundle_local_dir.'/after'
else
" make sure it's there
" otherwise clone it
" git clone https://github.com/gmarik/vundle.git ~/.vim/bundle/vundle
set rtp+=~/.vim/bundle/vundle
endif
call vundle#rc()
Bundle 'gmarik/vundle'
Bundle 'majutsushi/tagbar'
Bundle 'sjl/gundo.vim'
Bundle 'scrooloose/nerdtree'
Bundle 'scrooloose/syntastic'
Bundle 'Rykka/colorv.vim'
Bundle 'Rykka/galaxy.vim'
" ...
filetype plugin indent on " required!
let g:vimrc_bundle_loaded=1
endif "}}}
```
3. Install configured bundles:


+ 4
- 0
autoload/vundle.vim View File

@ -25,6 +25,7 @@ com! -nargs=? -bang BundleClean
com! -nargs=0 BundleDocs
\ call vundle#installer#helptags(g:bundles)
com! -bang BundleUpdateLocal call vundle#installer#update_local('!' == '<bang>', <q-args>)
if (has('signs'))
sign define Vu_error text=! texthl=Error
@ -38,6 +39,9 @@ endif
func! vundle#rc(...) abort
let g:bundle_local_dir = exists("g:bundle_local_dir") ?
\ expand(g:bundle_local_dir) : expand('$HOME/.vim/localbundle', 1)
let g:vundle_local = exists("g:vundle_local") ? g:vundle_local : 0
let g:bundle_dir = len(a:000) > 0 ? expand(a:1, 1) : expand('$HOME/.vim/bundle', 1)
let g:updated_bundles = []
let g:vundle_log = []


+ 3
- 3
autoload/vundle/config.vim View File

@ -1,14 +1,14 @@
func! vundle#config#bundle(arg, ...)
let bundle = vundle#config#init_bundle(a:arg, a:000)
call s:rtp_rm_a()
if g:vundle_local==0 | call s:rtp_rm_a() | endif
call add(g:bundles, bundle)
call s:rtp_add_a()
if g:vundle_local==0 | call s:rtp_add_a() | endif
return bundle
endf
func! vundle#config#init()
if !exists('g:bundles') | let g:bundles = [] | endif
call s:rtp_rm_a()
if g:vundle_local==0 | call s:rtp_rm_a() | endif
let g:bundles = []
endf


+ 65
- 0
autoload/vundle/installer.vim View File

@ -253,3 +253,68 @@ func! s:log(str) abort
call add(g:vundle_log, '['.strftime(fmt).'] '.a:str)
return a:str
endf
fun! vundle#installer#localdocs() abort
call s:helptags(g:bundle_local_dir)
return 'helptags'
endfun
func! vundle#installer#local() abort
return s:update_local()
endf
fun! s:update_local() abort "{{{
call s:log('')
call s:log('Remove dir of localbundle')
if has('win32') || has('win64')
let cmd = "rd /S /Q ".g:bundle_local_dir
let out = s:system(cmd)
else
let cmd = "rm -rf ".g:bundle_local_dir
endif
let out = s:system(cmd)
call s:log('$ '.cmd)
call s:log('> '.out)
call mkdir(g:bundle_local_dir, "p")
call s:log('')
call s:log('copy to localbundle ')
if has('win32') || has('win64')
let dirs = split(glob(g:bundle_dir."/*/"),"\n")
for dir in dirs
exe "cd /d ".dir
let cmd = "xcopy /E /Y /C /I * ".g:bundle_local_dir
let out = s:system(cmd)
call s:log('$ '.cmd)
call s:log('> '.out)
endfor
else
let cmd = "cp -rnl ".g:bundle_dir."/*/* ".g:bundle_local_dir
let out = s:system(cmd)
call s:log('$ '.cmd)
call s:log('> '.out)
endif
if 0 != v:shell_error
return 'error'
else
return 'updated'
end
endfun "}}}
function! vundle#installer#update_local(bang,...) "{{{
let bundles = (a:1 == '') ?
\ g:bundles :
\ map(copy(a:000), 'vundle#config#bundle(v:val, {})')
let names = vundle#scripts#bundle_names(map(copy(bundles), 'v:val.name_spec'))
call vundle#scripts#view('Installer',['" Update Bundle and install to '.expand(g:bundle_local_dir, 1)], names + ['LocalBundle','LocalHelptags'])
call s:process(a:bang, (a:bang ? 'add!' : 'add'))
call vundle#config#require(bundles)
endfunction "}}}

+ 53
- 0
autoload/vundle/local.vim View File

@ -0,0 +1,53 @@
" local bundle directory to increase vim speed.
" set &rtp to make sure the localbundle &rtp is prior to $VIMRUNTIME
"
" TODO clear the bundle list after local updating.
" or just don't add them to &rtp.
func! s:system(cmd) abort
return system(a:cmd)
endf
function! vundle#local#update(bang) "{{{
if a:bang
exec "BundleInstall!"
else
exec "BundleInstall"
endif
cd ~/.vim
if has('win32') || has('win64')
let t = s:system("rd /S /Q localbundle")
else
let t = s:system("rm -rf localbundle")
endif
let t = 0==t ? "Success" : t
echo "remove ~/.vim/localbundle\t:".t
let t = s:system("mkdir localbundle")
let t = 0==t ? "Success" : t
echo "mkdir ~/.vim/localbundle\t:".t
if has('win32') || has('win64')
let dirs = split(glob("~/.vim/bundle/*"),"\n")
let tar = expand("~/.vim/localbundle/")
for dir in dirs
exe "cd ".dir
let t = s:system("xcopy /E /Y /C /I * ".tar)
endfor
else
let t = s:system("cp -rnl bundle/*/* localbundle")
endif
let t = 0==t ? "Success" : t
echo "copy to ~/.vim/localbundle\t:".t
try
helptags ~/.vim/localbundle/doc
echo "helptags ~/.vim/localbundle\t:Success"
catch
echo "helptags ~/.vim/localbundle\t:".v:exception
endtry
echo "Local Updating Finish!"
endfunction "}}}

+ 7
- 0
autoload/vundle/scripts.vim View File

@ -109,6 +109,7 @@ func! vundle#scripts#view(title, headers, results)
setl syntax=vim
syn keyword vimCommand Bundle
syn keyword vimCommand Helptags
syn keyword vimCommand LocalBundle LocalHelptags
com! -buffer -bang -nargs=1 DeleteBundle
\ call vundle#installer#run('vundle#installer#delete', split(<q-args>,',')[0], ['!' == '<bang>', <args>])
@ -122,6 +123,12 @@ func! vundle#scripts#view(title, headers, results)
com! -buffer -bang -nargs=0 InstallHelptags
\ call vundle#installer#run('vundle#installer#docs', 'helptags', [])
com! -buffer -bang -nargs=0 InstallLocalHelptags
\ call vundle#installer#run('vundle#installer#localdocs', 'localhelptags', [])
com! -buffer -bang -nargs=0 InstallLocalBundle
\ call vundle#installer#run('vundle#installer#local', 'localbundle', [])
com! -buffer -nargs=0 VundleLog call s:view_log()
com! -buffer -nargs=0 VundleChangelog call s:view_changelog()


Loading…
Cancel
Save