awesome installer
This commit is contained in:
parent
139498855b
commit
eca5e06a55
@ -8,7 +8,7 @@ com! -nargs=+ Bundle
|
|||||||
\ call vundle#config#bundle(<args>)
|
\ call vundle#config#bundle(<args>)
|
||||||
|
|
||||||
com! -nargs=? -bang -complete=custom,vundle#scripts#complete BundleInstall
|
com! -nargs=? -bang -complete=custom,vundle#scripts#complete BundleInstall
|
||||||
\ call vundle#installer#install('!' == '<bang>', <q-args>)
|
\ call vundle#installer#new('!' == '<bang>', <q-args>)
|
||||||
|
|
||||||
com! -nargs=? -bang -complete=custom,vundle#scripts#complete Bundles
|
com! -nargs=? -bang -complete=custom,vundle#scripts#complete Bundles
|
||||||
\ call vundle#scripts#all('!'=='<bang>', <q-args>)
|
\ call vundle#scripts#all('!'=='<bang>', <q-args>)
|
||||||
|
@ -1,30 +1,72 @@
|
|||||||
func! vundle#installer#install(bang, ...) abort
|
func! vundle#installer#new(bang, ...) abort
|
||||||
if !isdirectory(g:bundle_dir) | call mkdir(g: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, errors] = s:install(a:bang, bundles)
|
let names = map(copy(bundles), 'v:val.name')
|
||||||
if empty(errors) | redraw! | end
|
call s:display(['" Installing'], names)
|
||||||
" TODO: handle error: let user know hen they need to restart Vim
|
|
||||||
call vundle#config#require(bundles)
|
|
||||||
|
|
||||||
let msg = 'No new bundles were installed'
|
setl cursorline norelativenumber nonu
|
||||||
if (!empty(installed))
|
exec ":1"
|
||||||
let msg = "Installed bundles:\n".join(map(installed, 'v:val.name'),"\n")
|
redraw!
|
||||||
|
|
||||||
|
for l in range(1,len(names))
|
||||||
|
exec ":+1"
|
||||||
|
redraw!
|
||||||
|
exec 'Install'.getline('.')
|
||||||
|
sleep 1m
|
||||||
|
endfor
|
||||||
|
|
||||||
|
redraw!
|
||||||
|
|
||||||
|
let helptags = vundle#installer#helptags(bundles)
|
||||||
|
echo 'Done! Helptags: '.len(helptags).' bundles processed'
|
||||||
|
endf
|
||||||
|
|
||||||
|
func! s:display(headers, results)
|
||||||
|
if !exists('s:browse') | let s:browse = tempname() | endif
|
||||||
|
let results = reverse(map(a:results, ' printf("Bundle! ' ."'%s'".'", v:val) '))
|
||||||
|
call writefile(a:headers + results, s:browse)
|
||||||
|
silent pedit `=s:browse`
|
||||||
|
|
||||||
|
wincmd P | wincmd H
|
||||||
|
|
||||||
|
setl ft=vundle
|
||||||
|
call vundle#scripts#setup_view()
|
||||||
|
endf
|
||||||
|
|
||||||
|
func! vundle#installer#install(bang, name) abort
|
||||||
|
if !isdirectory(g:bundle_dir) | call mkdir(g:bundle_dir, 'p') | endif
|
||||||
|
|
||||||
|
let b = vundle#config#init_bundle(a:name, {})
|
||||||
|
|
||||||
|
echo 'Installing '.b.name
|
||||||
|
|
||||||
|
let [err_code, status] = s:sync(a:bang, b)
|
||||||
|
|
||||||
|
redraw!
|
||||||
|
|
||||||
|
if 0 == err_code
|
||||||
|
if 'ok' == status
|
||||||
|
echo b.name.' installed'
|
||||||
|
exe ":sign place ".line('.')." line=".line('.')." name=VuOk buffer=" . bufnr("$")
|
||||||
|
elseif 'skip' == status
|
||||||
|
echo b.name.' already installed'
|
||||||
|
exe ":sign place ".line('.')." line=".line('.')." name=VuOk buffer=" . bufnr("$")
|
||||||
|
endif
|
||||||
|
else
|
||||||
|
echohl Error
|
||||||
|
echo 'Error installing "'.b.name
|
||||||
|
echohl None
|
||||||
|
exe ":sign place ".line('.')." line=".line('.')." name=VuEr buffer=" . bufnr("$")
|
||||||
|
sleep 1
|
||||||
endif
|
endif
|
||||||
call s:log(msg)
|
|
||||||
|
|
||||||
call vundle#installer#helptags(bundles)
|
|
||||||
endf
|
endf
|
||||||
|
|
||||||
func! vundle#installer#helptags(bundles) abort
|
func! vundle#installer#helptags(bundles) abort
|
||||||
let bundle_dirs = map(copy(a:bundles),'v:val.rtpath()')
|
let bundle_dirs = map(copy(a:bundles),'v:val.rtpath()')
|
||||||
let help_dirs = filter(bundle_dirs, 's:has_doc(v:val)')
|
let help_dirs = filter(bundle_dirs, 's:has_doc(v:val)')
|
||||||
call map(copy(help_dirs), 's:helptags(v:val)')
|
call map(copy(help_dirs), 's:helptags(v:val)')
|
||||||
if !empty(help_dirs)
|
|
||||||
call s:log('Helptags: '.len(help_dirs).' bundles processed')
|
|
||||||
endif
|
|
||||||
return help_dirs
|
return help_dirs
|
||||||
endf
|
endf
|
||||||
|
|
||||||
@ -34,7 +76,7 @@ func! vundle#installer#clean(bang) abort
|
|||||||
let x_dirs = filter(all_dirs, '0 > index(bundle_dirs, v:val)')
|
let x_dirs = filter(all_dirs, '0 > index(bundle_dirs, v:val)')
|
||||||
|
|
||||||
if empty(x_dirs)
|
if empty(x_dirs)
|
||||||
call s:log("All clean!")
|
echo "All clean!"
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -81,30 +123,10 @@ func! s:sync(bang, bundle) abort
|
|||||||
let cmd = 'git clone '.a:bundle.uri.' '.shellescape(a:bundle.path())
|
let cmd = 'git clone '.a:bundle.uri.' '.shellescape(a:bundle.path())
|
||||||
endif
|
endif
|
||||||
|
|
||||||
silent exec '!'.cmd
|
call system(cmd)
|
||||||
|
|
||||||
if 0 != v:shell_error
|
if 0 != v:shell_error
|
||||||
echohl Error | echo 'Error installing "'.a:bundle.name.'". Failed cmd: '.cmd | echohl None
|
|
||||||
return [v:shell_error, 'error']
|
return [v:shell_error, 'error']
|
||||||
end
|
end
|
||||||
return [0, 'ok']
|
return [0, 'ok']
|
||||||
endf
|
endf
|
||||||
|
|
||||||
func! s:install(bang, bundles) abort
|
|
||||||
let [installed, errors] = [[],[]]
|
|
||||||
|
|
||||||
for b in a:bundles
|
|
||||||
let [err_code, status] = s:sync(a:bang, b)
|
|
||||||
if 0 == err_code
|
|
||||||
if 'ok' == status | call add(installed, b) | endif
|
|
||||||
else
|
|
||||||
call add(errors, b)
|
|
||||||
endif
|
|
||||||
endfor
|
|
||||||
return [installed, errors]
|
|
||||||
endf
|
|
||||||
|
|
||||||
" TODO: make it pause after output in console mode
|
|
||||||
func! s:log(msg)
|
|
||||||
echo a:msg
|
|
||||||
endf
|
|
||||||
|
@ -25,23 +25,19 @@ func! vundle#scripts#complete(a,c,d)
|
|||||||
return join(s:load_scripts(0),"\n")
|
return join(s:load_scripts(0),"\n")
|
||||||
endf
|
endf
|
||||||
|
|
||||||
func! vundle#scripts#install() abort
|
|
||||||
let l = getline('.')
|
|
||||||
if l !~ '^Bundle '
|
|
||||||
echohl Error | echo 'Select Bundle to install'| echohl None
|
|
||||||
return 0
|
|
||||||
end
|
|
||||||
let line = substitute(substitute(l, '\s*Bundle\s*','','g'), "'",'','g')
|
|
||||||
call vundle#installer#install(0, line)
|
|
||||||
endf
|
|
||||||
|
|
||||||
func! vundle#scripts#setup_view() abort
|
func! vundle#scripts#setup_view() abort
|
||||||
|
setl cursorline norelativenumber nonu
|
||||||
setl hls ro noma ignorecase syntax=vim
|
setl hls ro noma ignorecase syntax=vim
|
||||||
|
|
||||||
syn keyword vimCommand Bundle
|
syn keyword vimCommand Bundle
|
||||||
|
|
||||||
|
sign define VuEr text=! texthl=Error
|
||||||
|
sign define VuOk text=* texthl=String
|
||||||
|
|
||||||
|
com! -buffer -bang -nargs=? InstallBundle call vundle#installer#install('!' == '<bang>', <q-args>)
|
||||||
|
|
||||||
nnoremap <buffer> q :wincmd q<CR>
|
nnoremap <buffer> q :wincmd q<CR>
|
||||||
nnoremap <buffer> i :call vundle#scripts#install()<CR>
|
nnoremap <buffer> i :exec 'Install'.getline('.')<CR>
|
||||||
nnoremap <buffer> r :Bundles
|
nnoremap <buffer> r :Bundles
|
||||||
nnoremap <buffer> c :BundleClean<CR>
|
nnoremap <buffer> c :BundleClean<CR>
|
||||||
nnoremap <buffer> C :BundleClean!<CR>
|
nnoremap <buffer> C :BundleClean!<CR>
|
||||||
|
Loading…
Reference in New Issue
Block a user