From 7d68d686bb44b96ae13cde3692635d45a0faad06 Mon Sep 17 00:00:00 2001 From: Rykka Date: Mon, 4 Jun 2012 22:34:54 +0800 Subject: [PATCH 01/21] add localbundle and it's vimrc sample --- README.md | 43 +++++++++++++++++++++++ autoload/vundle.vim | 4 +++ autoload/vundle/config.vim | 6 ++-- autoload/vundle/installer.vim | 65 +++++++++++++++++++++++++++++++++++ autoload/vundle/local.vim | 53 ++++++++++++++++++++++++++++ autoload/vundle/scripts.vim | 7 ++++ 6 files changed, 175 insertions(+), 3 deletions(-) create mode 100644 autoload/vundle/local.vim diff --git a/README.md b/README.md index 9de30ce..7df6be8 100644 --- a/README.md +++ b/README.md @@ -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: diff --git a/autoload/vundle.vim b/autoload/vundle.vim index 1ac74e1..e305b1c 100644 --- a/autoload/vundle.vim +++ b/autoload/vundle.vim @@ -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('!' == '', ) 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 = [] diff --git a/autoload/vundle/config.vim b/autoload/vundle/config.vim index 55c7d7d..69c19fa 100644 --- a/autoload/vundle/config.vim +++ b/autoload/vundle/config.vim @@ -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 diff --git a/autoload/vundle/installer.vim b/autoload/vundle/installer.vim index 38a2436..71714e6 100644 --- a/autoload/vundle/installer.vim +++ b/autoload/vundle/installer.vim @@ -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 "}}} diff --git a/autoload/vundle/local.vim b/autoload/vundle/local.vim new file mode 100644 index 0000000..a7b435e --- /dev/null +++ b/autoload/vundle/local.vim @@ -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 "}}} diff --git a/autoload/vundle/scripts.vim b/autoload/vundle/scripts.vim index a7ef724..f8b2c64 100644 --- a/autoload/vundle/scripts.vim +++ b/autoload/vundle/scripts.vim @@ -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(,',')[0], ['!' == '', ]) @@ -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() From c18cfa98e909a988163a19c9d1ef2e84f8ec726f Mon Sep 17 00:00:00 2001 From: Rykka Date: Mon, 4 Jun 2012 22:41:15 +0800 Subject: [PATCH 02/21] g:vundle_ --- README.md | 10 +++++----- autoload/vundle.vim | 4 ++-- autoload/vundle/installer.vim | 14 +++++++------- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 7df6be8..8f68f7b 100644 --- a/README.md +++ b/README.md @@ -54,7 +54,7 @@ ``` - Sample `.vimrc` For the using of `localbundle` + Sample `.vimrc` for the using of `localbundle` ```vim @@ -67,11 +67,11 @@ " 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' + let g:vundle_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' + if filereadable(expand(g:vundle_local_dir)."/autoload/vundle.vim") + exe 'set rtp^='.g:vundle_local_dir + exe 'set rtp+='.g:vundle_local_dir.'/after' else " make sure it's there " otherwise clone it diff --git a/autoload/vundle.vim b/autoload/vundle.vim index e305b1c..fba980a 100644 --- a/autoload/vundle.vim +++ b/autoload/vundle.vim @@ -39,8 +39,8 @@ 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_dir = exists("g:vundle_local_dir") ? + \ expand(g:vundle_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 = [] diff --git a/autoload/vundle/installer.vim b/autoload/vundle/installer.vim index 71714e6..c89350b 100644 --- a/autoload/vundle/installer.vim +++ b/autoload/vundle/installer.vim @@ -255,7 +255,7 @@ func! s:log(str) abort endf fun! vundle#installer#localdocs() abort - call s:helptags(g:bundle_local_dir) + call s:helptags(g:vundle_local_dir) return 'helptags' endfun @@ -268,16 +268,16 @@ 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 cmd = "rd /S /Q ".g:vundle_local_dir let out = s:system(cmd) else - let cmd = "rm -rf ".g:bundle_local_dir + let cmd = "rm -rf ".g:vundle_local_dir endif let out = s:system(cmd) call s:log('$ '.cmd) call s:log('> '.out) - call mkdir(g:bundle_local_dir, "p") + call mkdir(g:vundle_local_dir, "p") call s:log('') call s:log('copy to localbundle ') @@ -285,13 +285,13 @@ fun! s:update_local() abort "{{{ 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 cmd = "xcopy /E /Y /C /I * ".g:vundle_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 cmd = "cp -rnl ".g:bundle_dir."/*/* ".g:vundle_local_dir let out = s:system(cmd) call s:log('$ '.cmd) call s:log('> '.out) @@ -311,7 +311,7 @@ function! vundle#installer#update_local(bang,...) "{{{ \ 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 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')) From 0f06cd8ac2c3e8a8bf368a53c3161f2809087ba0 Mon Sep 17 00:00:00 2001 From: Rykka Date: Mon, 4 Jun 2012 23:16:19 +0800 Subject: [PATCH 03/21] 0 --- autoload/vundle/installer.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autoload/vundle/installer.vim b/autoload/vundle/installer.vim index c89350b..9a113f3 100644 --- a/autoload/vundle/installer.vim +++ b/autoload/vundle/installer.vim @@ -284,7 +284,7 @@ fun! s:update_local() abort "{{{ if has('win32') || has('win64') let dirs = split(glob(g:bundle_dir."/*/"),"\n") for dir in dirs - exe "cd /d ".dir + exe "cd /d " . shellescape(dir) let cmd = "xcopy /E /Y /C /I * ".g:vundle_local_dir let out = s:system(cmd) call s:log('$ '.cmd) From fbfdf1d0b61d6bebe08b40b60f235ff898c9b9dc Mon Sep 17 00:00:00 2001 From: Rykka Date: Mon, 4 Jun 2012 23:18:29 +0800 Subject: [PATCH 04/21] 0 --- autoload/vundle/installer.vim | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/autoload/vundle/installer.vim b/autoload/vundle/installer.vim index 9a113f3..e70bad9 100644 --- a/autoload/vundle/installer.vim +++ b/autoload/vundle/installer.vim @@ -284,8 +284,7 @@ fun! s:update_local() abort "{{{ if has('win32') || has('win64') let dirs = split(glob(g:bundle_dir."/*/"),"\n") for dir in dirs - exe "cd /d " . shellescape(dir) - let cmd = "xcopy /E /Y /C /I * ".g:vundle_local_dir + let cmd = "cd /d " . shellescape(dir) . " && xcopy /E /Y /C /I * ".g:vundle_local_dir let out = s:system(cmd) call s:log('$ '.cmd) call s:log('> '.out) From bcb6d563949f8e3f7eed00b2f1bc8b623fa45c1c Mon Sep 17 00:00:00 2001 From: Rykka Date: Mon, 4 Jun 2012 23:25:27 +0800 Subject: [PATCH 05/21] 0 --- autoload/vundle/installer.vim | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/autoload/vundle/installer.vim b/autoload/vundle/installer.vim index e70bad9..fffb555 100644 --- a/autoload/vundle/installer.vim +++ b/autoload/vundle/installer.vim @@ -265,32 +265,36 @@ 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 ".g:vundle_local_dir + let cmd = "rd /S /Q ".local_dir let out = s:system(cmd) else - let cmd = "rm -rf ".g:vundle_local_dir + 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 mkdir(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") + let dirs = split(glob(bundle_dir.'/*/'),'\n') for dir in dirs - let cmd = "cd /d " . shellescape(dir) . " && xcopy /E /Y /C /I * ".g:vundle_local_dir + let cmd = 'cd /d ' . shellescape(dir) . ' && xcopy /E /Y /C /I * '.local_dir + let cmd = '"'.cmd.'"' + let out = s:system(cmd) call s:log('$ '.cmd) call s:log('> '.out) endfor else - let cmd = "cp -rnl ".g:bundle_dir."/*/* ".g:vundle_local_dir + let cmd = "cp -rnl ".bundle_dir."/*/* ".local_dir let out = s:system(cmd) call s:log('$ '.cmd) call s:log('> '.out) From 7c94bfb4af5caae1a60ed54aa7750547ed3520b6 Mon Sep 17 00:00:00 2001 From: Rykka Date: Mon, 4 Jun 2012 23:29:50 +0800 Subject: [PATCH 06/21] 0 --- autoload/vundle/installer.vim | 2 -- 1 file changed, 2 deletions(-) diff --git a/autoload/vundle/installer.vim b/autoload/vundle/installer.vim index fffb555..d793fc1 100644 --- a/autoload/vundle/installer.vim +++ b/autoload/vundle/installer.vim @@ -287,8 +287,6 @@ fun! s:update_local() abort "{{{ let dirs = split(glob(bundle_dir.'/*/'),'\n') for dir in dirs let cmd = 'cd /d ' . shellescape(dir) . ' && xcopy /E /Y /C /I * '.local_dir - let cmd = '"'.cmd.'"' - let out = s:system(cmd) call s:log('$ '.cmd) call s:log('> '.out) From 1d839af1dc0cf267c72752f225d36573fe5453b1 Mon Sep 17 00:00:00 2001 From: Rykka Date: Mon, 4 Jun 2012 23:33:39 +0800 Subject: [PATCH 07/21] 0 --- autoload/vundle/installer.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autoload/vundle/installer.vim b/autoload/vundle/installer.vim index d793fc1..61c65ca 100644 --- a/autoload/vundle/installer.vim +++ b/autoload/vundle/installer.vim @@ -279,7 +279,7 @@ fun! s:update_local() abort "{{{ call s:log('$ '.cmd) call s:log('> '.out) - call mkdir(local_dir, "p") + call mkdir(g:vundle_local_dir, "p") call s:log('') call s:log('copy to localbundle ') From 66e96a613b1a48d41e8630a77762fc2fbc663a60 Mon Sep 17 00:00:00 2001 From: Rykka Date: Mon, 4 Jun 2012 23:36:14 +0800 Subject: [PATCH 08/21] 0 --- autoload/vundle/installer.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autoload/vundle/installer.vim b/autoload/vundle/installer.vim index 61c65ca..d6450a4 100644 --- a/autoload/vundle/installer.vim +++ b/autoload/vundle/installer.vim @@ -284,7 +284,7 @@ fun! s:update_local() abort "{{{ call s:log('') call s:log('copy to localbundle ') if has('win32') || has('win64') - let dirs = split(glob(bundle_dir.'/*/'),'\n') + let dirs = split(glob(g:bundle_dir.'/*/'),'\n') for dir in dirs let cmd = 'cd /d ' . shellescape(dir) . ' && xcopy /E /Y /C /I * '.local_dir let out = s:system(cmd) From ae637f484e05bc9d792837ab534d64e7946d1925 Mon Sep 17 00:00:00 2001 From: Rykka Date: Mon, 4 Jun 2012 23:41:24 +0800 Subject: [PATCH 09/21] 0 --- autoload/vundle/installer.vim | 1 + 1 file changed, 1 insertion(+) diff --git a/autoload/vundle/installer.vim b/autoload/vundle/installer.vim index d6450a4..4b56af2 100644 --- a/autoload/vundle/installer.vim +++ b/autoload/vundle/installer.vim @@ -287,6 +287,7 @@ fun! s:update_local() abort "{{{ let dirs = split(glob(g:bundle_dir.'/*/'),'\n') for dir in dirs let cmd = 'cd /d ' . shellescape(dir) . ' && xcopy /E /Y /C /I * '.local_dir + let cmd = "'".cmd."'" let out = s:system(cmd) call s:log('$ '.cmd) call s:log('> '.out) From 7f602407bdbbaacafec3fedc4b4616f99aa7f5dc Mon Sep 17 00:00:00 2001 From: Rykka Date: Mon, 4 Jun 2012 23:44:22 +0800 Subject: [PATCH 10/21] 0 --- autoload/vundle/installer.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autoload/vundle/installer.vim b/autoload/vundle/installer.vim index 4b56af2..73a17f9 100644 --- a/autoload/vundle/installer.vim +++ b/autoload/vundle/installer.vim @@ -287,7 +287,7 @@ fun! s:update_local() abort "{{{ let dirs = split(glob(g:bundle_dir.'/*/'),'\n') for dir in dirs let cmd = 'cd /d ' . shellescape(dir) . ' && xcopy /E /Y /C /I * '.local_dir - let cmd = "'".cmd."'" + " let cmd = "'".cmd."'" let out = s:system(cmd) call s:log('$ '.cmd) call s:log('> '.out) From 1dd97eca2ef8b6a2dd359bd6e4a970b9a23bac5d Mon Sep 17 00:00:00 2001 From: Rykka Date: Mon, 4 Jun 2012 23:47:07 +0800 Subject: [PATCH 11/21] 0 --- autoload/vundle/installer.vim | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/autoload/vundle/installer.vim b/autoload/vundle/installer.vim index 73a17f9..21f8e54 100644 --- a/autoload/vundle/installer.vim +++ b/autoload/vundle/installer.vim @@ -286,7 +286,8 @@ fun! s:update_local() abort "{{{ if has('win32') || has('win64') let dirs = split(glob(g:bundle_dir.'/*/'),'\n') for dir in dirs - let cmd = 'cd /d ' . shellescape(dir) . ' && xcopy /E /Y /C /I * '.local_dir + echo dir shellescape(dir."*") + let cmd = 'xcopy /E /Y /C /I '.shellescape(dir."*").' '.local_dir " let cmd = "'".cmd."'" let out = s:system(cmd) call s:log('$ '.cmd) From b70e5d5d27c738211e587a6260fb7f6a63bc8b95 Mon Sep 17 00:00:00 2001 From: Rykka Date: Mon, 4 Jun 2012 23:48:42 +0800 Subject: [PATCH 12/21] 0 --- autoload/vundle/installer.vim | 2 -- 1 file changed, 2 deletions(-) diff --git a/autoload/vundle/installer.vim b/autoload/vundle/installer.vim index 21f8e54..1a8d2c7 100644 --- a/autoload/vundle/installer.vim +++ b/autoload/vundle/installer.vim @@ -286,9 +286,7 @@ fun! s:update_local() abort "{{{ if has('win32') || has('win64') let dirs = split(glob(g:bundle_dir.'/*/'),'\n') for dir in dirs - echo dir shellescape(dir."*") let cmd = 'xcopy /E /Y /C /I '.shellescape(dir."*").' '.local_dir - " let cmd = "'".cmd."'" let out = s:system(cmd) call s:log('$ '.cmd) call s:log('> '.out) From 7f7ee1867319b2d27a03bed18c934835eb380006 Mon Sep 17 00:00:00 2001 From: Rykka Date: Tue, 5 Jun 2012 00:34:00 +0800 Subject: [PATCH 13/21] add win test localbundle vimrc --- test/win_localrc.vim | 67 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 test/win_localrc.vim diff --git a/test/win_localrc.vim b/test/win_localrc.vim new file mode 100644 index 0000000..fd061b3 --- /dev/null +++ b/test/win_localrc.vim @@ -0,0 +1,67 @@ +" vim -u test/vimrc +set nocompatible + +set nowrap +set et sw=4 +set noruler +set laststatus=2 +map :help +map :so % +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' +if filereadable(expand(g:vundle_local_dir)."/autoload/vundle.vim") + exe 'set rtp^='.g:vundle_local_dir + exe 'set rtp+='.g:vundle_local_dir.'/after' +else + exec 'set rtp+='.root.'/vundle' +endif + +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 From 3ed932e023e19a1c5bec5bb496a5c59ebb8c8436 Mon Sep 17 00:00:00 2001 From: Rykka Date: Tue, 5 Jun 2012 01:10:14 +0800 Subject: [PATCH 14/21] 0 --- README.md | 25 +++++++------------------ autoload/vundle.vim | 13 ++++++++++--- 2 files changed, 17 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 8f68f7b..7cd9bfa 100644 --- a/README.md +++ b/README.md @@ -60,39 +60,28 @@ " only load once if !exists("g:vimrc_bundle_loaded") + let g:vimrc_bundle_loaded=1 set nocompatible syntax on filetype off - " set it to 1 then vundle will only adding the localbundle dir to &rtp. + " set it to 1 to enable it + " 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' - - if filereadable(expand(g:vundle_local_dir)."/autoload/vundle.vim") - exe 'set rtp^='.g:vundle_local_dir - exe 'set rtp+='.g:vundle_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 + " set the localbundle directory + " let g:vundle_local_dir = '~/.vim/localbundle' + set rtp+=~/.vim/bundle/vundle 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 "}}} ``` diff --git a/autoload/vundle.vim b/autoload/vundle.vim index fba980a..6d2f30c 100644 --- a/autoload/vundle.vim +++ b/autoload/vundle.vim @@ -39,12 +39,19 @@ endif func! vundle#rc(...) abort - let g:vundle_local_dir = exists("g:vundle_local_dir") ? - \ expand(g:vundle_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 = [] 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^='.g:vundle_local_dir + exe 'set rtp+='.g:vundle_local_dir.'/after' + set rtp-=~/.vim/bundle/vundle + endif + call vundle#config#init() endf From a7ea654cd3cb89f47aafd106cf7313929c555ec9 Mon Sep 17 00:00:00 2001 From: Rykka Date: Tue, 5 Jun 2012 01:11:12 +0800 Subject: [PATCH 15/21] 0 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7cd9bfa..ce0dc37 100644 --- a/README.md +++ b/README.md @@ -58,7 +58,7 @@ ```vim - " only load once + " load only once to improve vimrc reloading speed if !exists("g:vimrc_bundle_loaded") let g:vimrc_bundle_loaded=1 set nocompatible From 688ad53e502f68dfb498864a2c88206095498eee Mon Sep 17 00:00:00 2001 From: Rykka Date: Tue, 5 Jun 2012 01:29:37 +0800 Subject: [PATCH 16/21] 0 --- autoload/vundle.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/autoload/vundle.vim b/autoload/vundle.vim index 6d2f30c..243aa45 100644 --- a/autoload/vundle.vim +++ b/autoload/vundle.vim @@ -48,8 +48,8 @@ func! vundle#rc(...) abort 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^='.g:vundle_local_dir - exe 'set rtp+='.g:vundle_local_dir.'/after' + exe 'set rtp^='.fnameescape(g:vundle_local_dir) + exe 'set rtp+='.fnameescape(g:vundle_local_dir.'/after') set rtp-=~/.vim/bundle/vundle endif From 3e68f79bf55782024f6aa592f9943ec7cebb3d84 Mon Sep 17 00:00:00 2001 From: Rykka Date: Tue, 5 Jun 2012 01:43:42 +0800 Subject: [PATCH 17/21] 0 --- test/win_localrc.vim | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/test/win_localrc.vim b/test/win_localrc.vim index fd061b3..31346a1 100644 --- a/test/win_localrc.vim +++ b/test/win_localrc.vim @@ -38,13 +38,9 @@ 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' -if filereadable(expand(g:vundle_local_dir)."/autoload/vundle.vim") - exe 'set rtp^='.g:vundle_local_dir - exe 'set rtp+='.g:vundle_local_dir.'/after' -else - exec 'set rtp+='.root.'/vundle' -endif +"let g:vundle_local_dir = '~/.vim/localbundle' + +exec 'set rtp+='.root.'/vundle' call vundle#rc(root) From ed3a4ccebeff2dafe3e7a3b44507ae55d2148096 Mon Sep 17 00:00:00 2001 From: Rykka Date: Tue, 5 Jun 2012 03:40:55 +0800 Subject: [PATCH 18/21] rm local.vim --- autoload/vundle/local.vim | 53 --------------------------------------- 1 file changed, 53 deletions(-) delete mode 100644 autoload/vundle/local.vim diff --git a/autoload/vundle/local.vim b/autoload/vundle/local.vim deleted file mode 100644 index a7b435e..0000000 --- a/autoload/vundle/local.vim +++ /dev/null @@ -1,53 +0,0 @@ -" 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 "}}} From a736eb551c915a2f68bd49a239b6164f28cbc78b Mon Sep 17 00:00:00 2001 From: Rykka Date: Tue, 5 Jun 2012 16:29:50 +0800 Subject: [PATCH 19/21] rmv &rtp after runtime it. --- autoload/vundle/config.vim | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/autoload/vundle/config.vim b/autoload/vundle/config.vim index 69c19fa..8606497 100644 --- a/autoload/vundle/config.vim +++ b/autoload/vundle/config.vim @@ -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 From e7e7c1bc145869ffc26f8afc7ca1f09110f70b2b Mon Sep 17 00:00:00 2001 From: Rykka Date: Tue, 5 Jun 2012 16:34:31 +0800 Subject: [PATCH 20/21] 0 --- autoload/vundle/installer.vim | 1 - 1 file changed, 1 deletion(-) diff --git a/autoload/vundle/installer.vim b/autoload/vundle/installer.vim index 1a8d2c7..b92feef 100644 --- a/autoload/vundle/installer.vim +++ b/autoload/vundle/installer.vim @@ -271,7 +271,6 @@ fun! s:update_local() abort "{{{ call s:log('Remove dir of localbundle') if has('win32') || has('win64') let cmd = "rd /S /Q ".local_dir - let out = s:system(cmd) else let cmd = "rm -rf ".local_dir endif From e43febf03ce33c1a4614b1a94d32fa8ce4043c3e Mon Sep 17 00:00:00 2001 From: Rykka Date: Tue, 5 Jun 2012 16:47:04 +0800 Subject: [PATCH 21/21] fnameescape bundle_dir --- autoload/vundle.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autoload/vundle.vim b/autoload/vundle.vim index 243aa45..fa64270 100644 --- a/autoload/vundle.vim +++ b/autoload/vundle.vim @@ -50,7 +50,7 @@ func! vundle#rc(...) abort 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') - set rtp-=~/.vim/bundle/vundle + exe 'set rtp-='.fnameescape(g:bundle_dir) endif call vundle#config#init()