Browse Source

evented approach

events
gmarik 15 years ago
parent
commit
58ae807ead
3 changed files with 51 additions and 24 deletions
  1. +16
    -2
      autoload/vundle.vim
  2. +34
    -21
      autoload/vundle/installer.vim
  3. +1
    -1
      test/vimrc

+ 16
- 2
autoload/vundle.vim View File

@ -33,9 +33,23 @@ func! vundle#rc(...) abort
call vundle#config#init() call vundle#config#init()
endf endf
augroup bundle#command-t augroup bundle#command-t
au! au!
au User BundleInstallPre echo 'ok'
au User BundleInstallPost echo 'Running command-t hooks'
au User BundleInstallPost !cd ruby/command-t && ruby extconf.rb && make clean && make au User BundleInstallPost !cd ruby/command-t && ruby extconf.rb && make clean && make
au User BundleInstallPost ![ -f doc/readme.txt -a -f doc/command-t.txt ] && rm doc/README.txt
au User BundleInstallPost echohl WarningMsg | echo 'Please restart Vim for command-t to work' | echohl None
augroup END
augroup vundle#bundle
au!
au User BundleInstallPre echo 'Installing '.g:bundle.name
au User BundleInstall call vundle#installer#sync(1, g:bundle)
au User BundleInstallPost echo 'Installed '.g:bundle.name
au User BundleInstalled echo 'Already Installed '.g:bundle.name
au User BundlesInstallPost call vundle#config#require(g:bundles)
au User BundlesInstallPost call vundle#installer#helptags(g:bundles)
au User BundlesInstallPost echo len(g:bundles).' '. "bundles installed"
augroup END augroup END

+ 34
- 21
autoload/vundle/installer.vim View File

@ -1,20 +1,45 @@
func! vundle#installer#install(bang, ...) abort func! vundle#installer#install(bang, ...) abort
if !isdirectory(g:vundle#bundle_dir) | call mkdir(g:vundle#bundle_dir, 'p') | endif
let bundles = (a:1 == '') ? let bundles = (a:1 == '') ?
\ s:reload_bundles() : \ s:reload_bundles() :
\ map(copy(a:000), 'vundle#config#init_bundle(v:val, {})') \ map(copy(a:000), 'vundle#config#init_bundle(v:val, {})')
let installed = s:install(a:bang, bundles)
redraw!
" TODO: handle error: let user know hen they need to restart Vim
call vundle#config#require(bundles)
let cwd = getcwd()
let new_bundles = []
for bundle in bundles
if !isdirectory(bundle.path()) | call mkdir(bundle.path(), 'p') | endif
call s:log("Installed bundles:\n".join((empty(installed) ?
\ ['no new bundless installed'] :
\ map(installed, 'v:val.name')),"\n"))
let g:bundle = bundle
call vundle#installer#helptags(bundles)
lcd `=bundle.path()`
call s:doautocmd('BundleInstallPre', 'vundle#bundle')
call s:doautocmd('BundleInstallPre', 'bundle#'.tolower(bundle.name))
if a:bang || !(s:installed(bundle))
call s:doautocmd('BundleInstall', 'vundle#bundle')
call s:doautocmd('BundleInstall', 'bundle#'.tolower(bundle.name))
call s:doautocmd('BundleInstallPost', 'vundle#bundle')
call s:doautocmd('BundleInstallPost', 'bundle#'.tolower(bundle.name))
call add(new_bundles, bundle)
else
call s:doautocmd('BundleInstalled', 'vundle#bundle')
call s:doautocmd('BundleInstalled', 'bundle#'.tolower(bundle.name))
endif
lcd `=cwd`
endfor
let g:bundles = new_bundles
call s:doautocmd('BundlesInstallPost', 'vundle#bundle')
endf
" TODO: verify whether autocommand already exists
" verbose autocmd User BundleInstall*
func! s:doautocmd(event, augroup_name)
if 0 <= index(s:load_augroups(), a:augroup_name)
exec 'doautocmd '.a:augroup_name.' User '.a:event
endif
endf endf
func! vundle#installer#helptags(bundles) abort func! vundle#installer#helptags(bundles) abort
@ -76,14 +101,6 @@ func! vundle#installer#sync(bang, bundle) abort
silent exec '!echo '.cmd | silent exec '!'.cmd silent exec '!echo '.cmd | silent exec '!'.cmd
let l:aug_name = tolower('bundle#'.a:bundle.name)
if 0 <= index(s:load_augroups(), aug_name)
lcd `=a:bundle.path()`
exec 'doautocmd '.l:aug_name.' User BundleInstallPost'
lcd `=cwd`
endif
return 1 return 1
endf endf
@ -93,10 +110,6 @@ func! s:load_augroups()
return augroups return augroups
endf endf
func! s:install(bang, bundles) abort
return filter(copy(a:bundles), 's:sync(a:bang, v:val)')
endf
" TODO: make it pause after output in console mode " TODO: make it pause after output in console mode
func! s:log(msg) func! s:log(msg)
echo a:msg echo a:msg


+ 1
- 1
test/vimrc View File

@ -19,7 +19,7 @@ Bundle 'altercation/vim-colors-solarized'
Bundle 'nelstrom/vim-mac-classic-theme.git' Bundle 'nelstrom/vim-mac-classic-theme.git'
" full uri " full uri
Bundle 'git@github.com:gmarik/ingretu.git'
" Bundle 'git@github.com:gmarik/ingretu.git'
" short uri " short uri
Bundle 'gh:gmarik/snipmate.vim.git' Bundle 'gh:gmarik/snipmate.vim.git'
Bundle 'github:mattn/gist-vim.git' Bundle 'github:mattn/gist-vim.git'


Loading…
Cancel
Save