Browse Source

Merge e43febf03c into 8e9b933ed4

pull/179/merge
Rykka 14 years ago
parent
commit
e45d8b06eb
6 changed files with 185 additions and 3 deletions
  1. +32
    -0
      README.md
  2. +11
    -0
      autoload/vundle.vim
  3. +7
    -3
      autoload/vundle/config.vim
  4. +65
    -0
      autoload/vundle/installer.vim
  5. +7
    -0
      autoload/vundle/scripts.vim
  6. +63
    -0
      test/win_localrc.vim

+ 32
- 0
README.md View File

@ -53,6 +53,38 @@
" NOTE: comments after Bundle command are not allowed..
```
Sample `.vimrc` for the using of `localbundle`
```vim
" load only once to improve vimrc reloading speed
if !exists("g:vimrc_bundle_loaded")
let g:vimrc_bundle_loaded=1
set nocompatible
syntax on
filetype off
" set it to 1 to enable it
" then vundle will only adding the localbundle dir to &rtp.
let g:vundle_local = 1
" set the localbundle directory
" let g:vundle_local_dir = '~/.vim/localbundle'
set rtp+=~/.vim/bundle/vundle
call vundle#rc()
Bundle 'gmarik/vundle'
Bundle 'scrooloose/nerdtree'
Bundle 'Rykka/colorv.vim'
Bundle 'Rykka/galaxy.vim'
" ...
filetype plugin indent on " required!
endif "}}}
```
3. Install configured bundles:


+ 11
- 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
@ -42,5 +43,15 @@ func! vundle#rc(...) abort
let g:updated_bundles = []
let g:vundle_log = []
let g:vundle_changelog = ['Updated Bundles:']
let g:vundle_local = exists("g:vundle_local") ? g:vundle_local : 0
let g:vundle_local_dir = exists("g:vundle_local_dir") ?
\ expand(g:vundle_local_dir) : expand('$HOME/.vim/localbundle', 1)
if filereadable(g:vundle_local_dir."/autoload/vundle.vim") && g:vundle_local
exe 'set rtp^='.fnameescape(g:vundle_local_dir)
exe 'set rtp+='.fnameescape(g:vundle_local_dir.'/after')
exe 'set rtp-='.fnameescape(g:bundle_dir)
endif
call vundle#config#init()
endf

+ 7
- 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
@ -20,6 +20,10 @@ func! vundle#config#require(bundles) abort
exec 'runtime! '.b.name.'/plugin/*.vim'
exec 'runtime! '.b.name.'/after/*.vim'
call s:rtp_rm(g:bundle_dir)
if g:vundle_local!=0
exec 'runtime! '.b.name.'/autoload/*.vim'
call s:rtp_rm(b.rtpath)
endif
endfor
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:vundle_local_dir)
return 'helptags'
endfun
func! vundle#installer#local() abort
return s:update_local()
endf
fun! s:update_local() abort "{{{
let local_dir = shellescape(g:vundle_local_dir)
let bundle_dir = shellescape(g:bundle_dir)
call s:log('')
call s:log('Remove dir of localbundle')
if has('win32') || has('win64')
let cmd = "rd /S /Q ".local_dir
else
let cmd = "rm -rf ".local_dir
endif
let out = s:system(cmd)
call s:log('$ '.cmd)
call s:log('> '.out)
call mkdir(g:vundle_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
let cmd = 'xcopy /E /Y /C /I '.shellescape(dir."*").' '.local_dir
let out = s:system(cmd)
call s:log('$ '.cmd)
call s:log('> '.out)
endfor
else
let cmd = "cp -rnl ".bundle_dir."/*/* ".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:vundle_local_dir, 1)], names + ['LocalBundle','LocalHelptags'])
call s:process(a:bang, (a:bang ? 'add!' : 'add'))
call vundle#config#require(bundles)
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()


+ 63
- 0
test/win_localrc.vim View File

@ -0,0 +1,63 @@
" vim -u test/vimrc
set nocompatible
set nowrap
set et sw=4
set noruler
set laststatus=2
map <F1> :help <c-r><c-w> <CR>
map <F5> :so %<CR>
let mapleader=" "
set bs=start
nno < <<
nno > >>
let root = '~/.vim/bundle'
if !isdirectory(root)
mkdir(root,'p')
endif
" NOTE: should change 'Rykka/vundle' to the offical repo
let src = 'http://github.com/Rykka/vundle.git'
" let src = '~/.vim/bundle/vundle/.git'
" Vundle Options
" let g:vundle_default_git_proto = 'git'
if !isdirectory(root.'\vundle')
exec '!git clone '.src.' '.shellescape(root.'\vundle', 1)
endif
filetype off
syntax on
runtime macros/matchit.vim
" 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:vundle_local_dir = '~/.vim/localbundle'
exec 'set rtp+='.root.'/vundle'
call vundle#rc(root)
Bundle "Rykka/vundle"
Bundle 'Rykka/colorv.vim'
Bundle 'Rykka/galaxy.vim'
filetype plugin indent on " Automatically detect file types.
set wildignore+=doc " should not break helptags
set wildignore+=.git " should not break clone
set wildignore+=.git/* " should not break clone
set wildignore+=*/.git/*
" TODO: helptags fails with this
" set wildignore+=doc/* " should not break clone
" set wildignore+=*/doc/*
"au VimEnter * BundleInstall
colorscheme galaxy

Loading…
Cancel
Save