@ -1,19 +1,63 @@
func ! vundle #installer #install ( bang , ...) abort
if ! isdirectory ( g :bundle_dir ) | call mkdir ( g :bundle_dir , 'p' ) | endif
if ! isdirectory ( g :vundle #bundle_dir ) | call mkdir ( g :vundle #bundle_dir , 'p' ) | endif
let bundles = ( a :1 = = '' ) ?
\ s :reload_bundles ( ) :
\ map ( copy ( a :000 ) , 'vundle#config#init_bundle(v:val, {})' )
\ [s :find_or_init_by_name ( a :1 ) ]
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 = []
call s :log ( "Installed bundles:\n" .join ( ( empty ( installed ) ?
\ ['no new bundles installed' ] :
\ map ( installed , 'v:val.name' ) ) , "\n" ) )
for bundle in bundles
if ! isdirectory ( bundle .path ( ) ) | call mkdir ( bundle .path ( ) , 'p' ) | endif
call vundle #installer #helptags ( bundles )
let [name , g :bundle ] = [tolower ( bundle .name ) , bundle ]
lcd `= bundle .path ( ) `
if a :bang | | ! ( bundle .installed ( ) )
call s :doautocmd ( 'BundleInstallPre' , 'vundle#bundle' )
call s :doautocmd ( 'BundleInstallPre' , 'bundle#' .name )
call s :doautocmd ( 'BundleInstallPre' , 'user#' .name )
call s :doautocmd ( 'BundleInstall' , 'vundle#bundle' )
call s :doautocmd ( 'BundleInstall' , 'bundle#' .name )
call s :doautocmd ( 'BundleInstall' , 'user#' .name )
call s :doautocmd ( 'BundleInstallPost' , 'vundle#bundle' )
call s :doautocmd ( 'BundleInstallPost' , 'bundle#' .name )
call s :doautocmd ( 'BundleInstallPost' , 'user#' .name )
call add ( new_bundles , bundle )
else
call s :doautocmd ( 'BundleInstalled' , 'vundle#bundle' )
call s :doautocmd ( 'BundleInstalled' , 'bundle#' .name )
call s :doautocmd ( 'BundleInstalled' , 'user#' .name )
endif
lcd `= cwd `
endfor
let g :bundles = new_bundles
call s :doautocmd ( 'BundlesInstallPost' , 'vundle#bundle' )
call s :doautocmd ( 'BundlesInstallPost' , 'user#bundle' )
endf
" TODO: improve this
" TODO: init_bundle should happen first though to get proper bundle name
func ! s :find_or_init_by_name ( name )
let matches = filter ( copy ( g :vundle #bundles ) , 'v:val.name == a:name' )
if ( ! empty ( matches ) )
return matches [0 ] "assuming only 1 match may happen
endif
return vundle #config #init_bundle ( 0 , a :name , {})
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
func ! vundle #installer #helptags ( bundles ) abort
@ -27,8 +71,8 @@ func! vundle#installer#helptags(bundles) abort
endf
func ! vundle #installer #clean ( bang ) abort
let bundle_dirs = map ( copy ( g :bundles ) , 'v:val.path()' )
let all_dirs = split ( globpath ( g :bundle_dir , '*' ) , "\n" )
let bundle_dirs = map ( copy ( g :vundle #bundles ) , 'v:val.path()' )
let all_dirs = split ( globpath ( g :vundle #bundle_dir , '*' ) , "\n" )
let x_dirs = filter ( all_dirs , '0 > index(bundle_dirs, v:val)' )
if empty ( x_dirs )
@ -48,7 +92,7 @@ func! s:reload_bundles()
" TODO: obtain Bundles without sourcing .vimrc
if filereadable ( $MYVIMRC ) | silent source $MYVIMRC | endif
if filereadable ( $MYGVIMRC ) | silent source $MYGVIMRC | endif
return g :bundles
return g :vundle #bundles
endf
func ! s :has_doc ( rtp ) abort
@ -65,9 +109,9 @@ func! s:helptags(rtp) abort
endtry
endf
func ! s :sync ( bang , bundle ) abort
let git_dir = expand ( a :bundle .path ( ) .'/.git/' )
if isdirectory ( git_dir )
func ! vundle #installer #sync ( bang , bundle ) abort
if a :bundle .nosync ( ) | return a :bang | endif
if a :bundle .installed ( )
if ! ( a :bang ) | return 0 | endif
let cmd = 'cd ' .shellescape ( a :bundle .path ( ) ) .' && git pull'
@ -78,12 +122,17 @@ func! s:sync(bang, bundle) abort
else
let cmd = 'git clone ' .a :bundle .uri .' ' .shellescape ( a :bundle .path ( ) )
endif
silent exec '!' .cmd
" exec '!echo '.shellescape(cmd)
silent exec '!' .cmd
return 1
endf
func ! s :install ( bang , bundles ) abort
return filter ( copy ( a :bundles ) , 's:sync(a:bang, v:val)' )
func ! s :load_augroups ( )
redir = > v | silent verbose augroup | redir END
let augroups = map ( split ( v , '[\n\r\t\ ]\+' ) , 'tolower(v:val)' )
return augroups
endf
" TODO: make it pause after output in console mode