LocalBundle for Vundle #179

Open
wants to merge 22 commits into
from

Conversation

Projects
None yet
3 participants

Rykka commented Jun 4, 2012

localbundle implementation.
no &rtp for bundles but only one localbundle directory.
also a windows_local_rc test included.

I have write a post about it.

Please have a look.

http://rykka.blogspot.com/2012/06/localbundle-for-vundle.html

Rykka closed this Jun 4, 2012

Rykka reopened this Jun 4, 2012

Contributor

gmarik commented Jun 11, 2012

Hey @Rykka
I'm not sure if I understand the whole idea behind this...
Also is having "0" as commit message a good idea?

Let me know!
Thanks

Rykka commented Jun 11, 2012

Please see the diff. https://github.com/gmarik/vundle/pull/179/files
The 0 commit is for those typo fix and misc things.

It include a cmd
:BundleUpdateLocal which acts mostly the same as :BundleInstall

But it will copy all bundle file into ~/.vim/localbundle/
And helptag there.
And not adding these path of bundles in to &rtp.
it only add ~/.vim/localbundle

Two options for this command.

" 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'

Evenmore , It will remove the g:bundle_dir if it find vundle in localbundle

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

So it's faster when you sourcing files. when 'load syntax/plugin autoload/help', also increase loading speed.

It's window is added and including the installing tips and logs.
And it's tested in Windows XP for the command.
the win_localrc is modified from testrc mainly with this:

if !isdirectory(root.'\vundle')
  exec '!git clone '.src.' '.shellescape(root.'\vundle', 1)
endif

Also , I think you should change the default vimrc in intro.
As syntax on is really a heavy command.
these part should be loaded only once for faster vimrc reloading speed.

if !exists("g:vimrc_bundle_loaded")
    let g:vimrc_bundle_loaded=1
    ...
endif

@Rykka Rykka commented on the diff Jun 11, 2012

autoload/vundle/installer.vim
+ 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
@Rykka

Rykka Jun 11, 2012

hard link for linux.
so no need to run command after modify scripts in bundle except adding files.

@Rykka Rykka commented on the diff Jun 11, 2012

autoload/vundle/installer.vim
+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
@Rykka

Rykka Jun 11, 2012

remove dir to keep the folder clean.

@Rykka Rykka commented on the diff Jun 11, 2012

test/win_localrc.vim
+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)
@Rykka

Rykka Jun 11, 2012

we need escape it within ,otherwise it's a string like '"~\xxx\xxx"\vundle'

@Rykka Rykka commented on an outdated diff Jun 11, 2012

+ 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'
@Rykka

Rykka Jun 11, 2012

mostly the same with the intro vimrc.
except adding the loaded check. and vundle_local option intro.
These names may need change at your convenience.

@Rykka Rykka commented on the diff Jun 11, 2012

autoload/vundle/installer.vim
+ 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
@Rykka

Rykka Jun 11, 2012

for windows. seems we could only copy from one folder each time

@Rykka Rykka commented on the diff Jun 11, 2012

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('!' == '<bang>', <q-args>)
@Rykka

Rykka Jun 11, 2012

the long name need to be change for a better name.

Contributor

jdevera commented Jun 11, 2012

Does this mean that all plugins get installed in one single directory? I hope not, it would seem like a step back, no?

Contributor

gmarik commented Jun 12, 2012

@jdevera this is tradeoff you get to pay for speedup, there's #131 already for this.
But to be hones we need to see numbers/benchmark to start with.
After this we could consider whether adding complexity worth the effort

Rykka commented Jun 12, 2012

@jdevera
all plugins are still installed in their bundle directory.
But copied to a single folder after installed to improve performance.

@gmarik see ':h runtimepath'

    Note that, unlike 'path', no wildcards like "**" are allowed.  Normal
wildcards are allowed, but can significantly slow down searching for
runtime files.  For speed, use as few items as possible and avoid
wildcards.
See |:runtime|.

another advantage of this is that , all 'trash' file like '*.pyc,tags' will be generated under localbundle which will not effect the bundle dir.

but if a script need compiled file , you should still put compiled file in
your bundle directory.

Contributor

jdevera commented Jun 14, 2012

Oh I see, that is a pretty cool idea, then.

Contributor

jdevera commented Jun 14, 2012

@Rykka , about the "0" commits, you can squash several commits into one before you push, so all those can go into one single commit, or several, but better organised.

Rykka commented Jun 14, 2012

@jdevera
Got it, Thanks.

Rykka commented Sep 25, 2012

a seperated plugin is added as https://github.com/Rykka/localbundle.vim

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment