Skip to content

Commit

Permalink
Updating to the latest version of Vundle
Browse files Browse the repository at this point in the history
  • Loading branch information
spicycode committed Sep 7, 2011
1 parent 8948d06 commit c5809af
Show file tree
Hide file tree
Showing 8 changed files with 420 additions and 128 deletions.
37 changes: 16 additions & 21 deletions vundle.git/README.md
Expand Up @@ -2,6 +2,8 @@

[Vundle] is short for **V**imb**undle** and is a [Vim] plugin manager.

![Vundle-installer](https://lh3.googleusercontent.com/-4EnLqLpEZlk/TlqXWpgWxOI/AAAAAAAAHRw/oBAl6s1hj7U/vundle-install2.png)

## Quick start

1. Setup [Vundle]:
Expand Down Expand Up @@ -29,7 +31,7 @@
"
" original repos on github
Bundle 'tpope/vim-fugitive'
Bundle 'lokaltog/vim-easymotion'
Bundle 'Lokaltog/vim-easymotion'
Bundle 'rstacruz/sparkup', {'rtp': 'vim/'}
" vim-scripts repos
Bundle 'L9'
Expand All @@ -42,19 +44,13 @@
filetype plugin indent on " required!
"
" Brief help
" :BundleList - list configured bundles
" :BundleInstall(!) - install(update) bundles
" :BundleSearch(!) foo - search(or refresh cache first) for foo
" :BundleClean(!) - confirm(or auto-approve) removal of unused bundles
"
" :BundleInstall - install bundles (won't update installed)
" :BundleInstall! - update if installed
"
" :Bundles foo - search for foo
" :Bundles! foo - refresh cached list and search for foo
"
" :BundleClean - confirm removal of unused bundles
" :BundleClean! - remove without confirmation
"
" see :h vundle for more details
" or wiki for FAQ
" Note: comments after Bundle command are not allowed..
" see :h vundle for more details or wiki for FAQ
" NOTE: comments after Bundle command are not allowed..
```

Expand Down Expand Up @@ -126,12 +122,11 @@ see [wiki](/gmarik/vundle/wiki)
* √ vim documentation
* √ put vundle to bundles/ too(will fix vundle help)
* √ tests
* improve error handling
* handle dependencies
* √ improve error handling
* allow specify revision/version?
* search by description as well
* handle dependencies
* show description in search results
* instead sourcing .vimrc before installation come up with another solution
* search by description as well
* make it rock!

[Vundle]:http://github.com/gmarik/vundle
Expand All @@ -142,7 +137,7 @@ see [wiki](/gmarik/vundle/wiki)
[all available vim scripts]:http://vim-scripts.org/vim/scripts.html

[install]:https://github.com/gmarik/vundle/blob/master/doc/vundle.txt#L110-124
[update]:https://github.com/gmarik/vundle/blob/master/doc/vundle.txt#L126-131
[search]:https://github.com/gmarik/vundle/blob/master/doc/vundle.txt#L133-155
[clean]:https://github.com/gmarik/vundle/blob/master/doc/vundle.txt#L157-169
[interactive mode]:https://github.com/gmarik/vundle/blob/master/doc/vundle.txt#L172-205
[update]:https://github.com/gmarik/vundle/blob/master/doc/vundle.txt#L128-133
[search]:https://github.com/gmarik/vundle/blob/master/doc/vundle.txt#L135-157
[clean]:https://github.com/gmarik/vundle/blob/master/doc/vundle.txt#L167-179
[interactive mode]:https://github.com/gmarik/vundle/blob/master/doc/vundle.txt#L183-209
22 changes: 15 additions & 7 deletions vundle.git/autoload/vundle.vim
Expand Up @@ -8,27 +8,35 @@ com! -nargs=+ Bundle
\ call vundle#config#bundle(<args>)

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 BundleSearch
\ call vundle#scripts#all('!'=='<bang>', <q-args>)

com! -nargs=? -bang -complete=custom,vundle#scripts#complete Bundles
\ call vundle#scripts#all('!'=='<bang>', <q-args>)

com! -nargs=0 -bang BundleList
\ call vundle#installer#list('!'=='<bang>')

com! -nargs=? -bang BundleClean
\ call vundle#installer#clean('!' == '<bang>')

com! -nargs=0 BundleDocs
\ call vundle#installer#helptags(g:bundles)

" deprecated in favor of Bundles
com! -nargs=? -bang BundleSearch
\ call vundle#scripts#all('!' == '<bang>', <q-args>)


au Filetype vundle call vundle#scripts#setup_view()
au Syntax vim syn keyword vimCommand Bundle
if (has('signs'))
sign define Vu_error text=! texthl=Error
sign define Vu_active text=> texthl=Comment
sign define Vu_todate text=. texthl=Comment
sign define Vu_updated text=+ texthl=Comment
sign define Vu_deleted text=- texthl=Comment
endif


func! vundle#rc(...) abort
let g:bundle_dir = len(a:000) > 0 ? expand(a:1) : expand('$HOME/.vim/bundle')
let g:vundle_log = []
call vundle#config#init()
endf
6 changes: 5 additions & 1 deletion vundle.git/autoload/vundle/config.vim
Expand Up @@ -40,9 +40,13 @@ endf

func! s:parse_name(arg)
let arg = a:arg

if arg =~? '^\s*\(gh\|github\):\S\+'
\ || arg =~? '^[a-z0-9][a-z0-9-]*/[^/]\+$'
let uri = 'https://github.com/'.split(arg, ':')[-1]
if uri !~? '\.git$'
let uri .= '.git'
endif
let name = substitute(split(uri,'\/')[-1], '\.git\s*$','','i')
elseif arg =~? '^\s*\(git@\|git://\)\S\+'
\ || arg =~? '\(file\|https\?\)://'
Expand All @@ -53,7 +57,7 @@ func! s:parse_name(arg)
let name = arg
let uri = 'https://github.com/vim-scripts/'.name.'.git'
endif
return {'name': name, 'uri': uri }
return {'name': name, 'uri': uri, 'name_spec': arg }
endf

func! s:rtp_rm_a()
Expand Down
203 changes: 168 additions & 35 deletions vundle.git/autoload/vundle/installer.vim
@@ -1,54 +1,171 @@
func! vundle#installer#install(bang, ...) abort
if !isdirectory(g:bundle_dir) | call mkdir(g:bundle_dir, 'p') | endif
func! vundle#installer#new(bang, ...) abort
let bundles = (a:1 == '') ?
\ s:reload_bundles() :
\ g:bundles :
\ 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
let names = vundle#scripts#bundle_names(map(copy(bundles), 'v:val.name_spec'))
call vundle#scripts#view('Installer',['" Installing bundles to '.expand(g:bundle_dir)], names + ['Helptags'])

call s:process(a:bang, (a:bang ? 'add!' : 'add'))

call vundle#config#require(bundles)
endf


func! s:process(bang, cmd)
let msg = ''

redraw!
sleep 1m

let lines = (getline('.','$')[0:-2])

for line in lines
redraw!

exec ':norm '.a:cmd

if 'error' == g:vundle_last_status
let msg = 'With errors; press l to view log'
endif

" goto next one
exec ':+1'

setl nomodified
endfor

redraw!
echo 'Done! '.msg
endf

func! vundle#installer#run(func_name, name, ...) abort
let n = a:name

echo 'Processing '.n
call s:sign('active')

sleep 1m

let status = call(a:func_name, a:1)

call s:sign(status)

redraw!

if 'updated' == status
echo n.' installed'
elseif 'todate' == status
echo n.' already installed'
elseif 'deleted' == status
echo n.' deleted'
elseif 'error' == status
echohl Error
echo 'Error processing '.n
echohl None
sleep 1
else
throw 'whoops, unknown status:'.status
endif

let g:vundle_last_status = status

return status
endf

func! s:sign(status)
if (!has('signs'))
return
endif

call s:log("Installed bundles:\n".join((empty(installed) ?
\ ['no new bundles installed'] :
\ map(installed, 'v:val.name')),"\n"))
exe ":sign place ".line('.')." line=".line('.')." name=Vu_". a:status ." buffer=" . bufnr("%")
endf

call vundle#installer#helptags(bundles)
func! vundle#installer#install_and_require(bang, name) abort
let result = vundle#installer#install(a:bang, a:name)
let b = vundle#config#init_bundle(a:name, {})
call vundle#config#require([b])
return result
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, {})

return s:sync(a:bang, b)
endf

func! vundle#installer#docs() abort
call vundle#installer#helptags(g:bundles)
return 'updated'
endf

func! vundle#installer#helptags(bundles) abort
let bundle_dirs = map(copy(a:bundles),'v:val.rtpath()')
let help_dirs = filter(bundle_dirs, 's:has_doc(v:val)')

call s:log('')
call s:log('Helptags:')

call map(copy(help_dirs), 's:helptags(v:val)')
if !empty(help_dirs)
call s:log('Helptags: done. '.len(help_dirs).' bundles processed')
endif

call s:log('Helptags: '.len(help_dirs).' bundles processed')

return help_dirs
endf

func! vundle#installer#list(bang) abort
let bundles = vundle#scripts#bundle_names(map(copy(g:bundles), 'v:val.name_spec'))
call vundle#scripts#view('list', ['" My Bundles'], bundles)
redraw!
echo len(g:bundles).' bundles configured'
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 x_dirs = filter(all_dirs, '0 > index(bundle_dirs, v:val)')

if empty(x_dirs)
call s:log("All clean!")
return
let headers = ['" All clean!']
let names = []
else
let headers = ['" Removing bundles:']
let names = vundle#scripts#bundle_names(map(copy(x_dirs), 'fnamemodify(v:val, ":t")'))
end

if (a:bang || input('Are you sure you want to remove '.len(x_dirs).' bundles? [ y/n ]:') =~? 'y')
let cmd = (has('win32') || has('win64')) ?
\ 'rmdir /S /Q' :
\ 'rm -rf'
exec '!'.cmd.' '.join(map(x_dirs, 'shellescape(v:val)'), ' ')
call vundle#scripts#view('clean', headers, names)
redraw!

if (a:bang || empty(names) || input('Continue ? [ y/n ]:') =~? 'y')
call s:process(a:bang, 'D')
endif
endf

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

func! vundle#installer#delete(bang, dir_name) abort

let cmd = (has('win32') || has('win64')) ?
\ 'rmdir /S /Q' :
\ 'rm -rf'

let bundle = vundle#config#init_bundle(a:dir_name, {})
let cmd .= ' '.shellescape(bundle.path())

let out = s:system(cmd)

call s:log('')
call s:log('Bundle '.a:dir_name)
call s:log('$ '.cmd)
call s:log('> '.out)

if 0 != v:shell_error
return 'error'
else
return 'deleted'
endif
endf

func! s:has_doc(rtp) abort
Expand All @@ -58,17 +175,19 @@ func! s:has_doc(rtp) abort
endf

func! s:helptags(rtp) abort
let doc_path = a:rtp.'/doc/'
call s:log(':helptags '.doc_path)
try
helptags `=a:rtp.'/doc/'`
helptags `=doc_path`
catch
echohl Error | echo "Error generating helptags in ".a:rtp | echohl None
call s:log("> Error running :helptags ".doc_path)
endtry
endf

func! s:sync(bang, bundle) abort
let git_dir = expand(a:bundle.path().'/.git/')
if isdirectory(git_dir)
if !(a:bang) | return 0 | endif
if !(a:bang) | return 'todate' | endif
let cmd = 'cd '.shellescape(a:bundle.path()).' && git pull'

if (has('win32') || has('win64'))
Expand All @@ -78,15 +197,29 @@ func! s:sync(bang, bundle) abort
else
let cmd = 'git clone '.a:bundle.uri.' '.shellescape(a:bundle.path())
endif
silent exec '!'.cmd
return 1

let out = s:system(cmd)
call s:log('')
call s:log('Bundle '.a:bundle.name_spec)
call s:log('$ '.cmd)
call s:log('> '.out)

if 0 != v:shell_error
return 'error'
end

if out =~# 'up-to-date'
return 'todate'
end

return 'updated'
endf

func! s:install(bang, bundles) abort
return filter(copy(a:bundles), 's:sync(a:bang, v:val)')
func! s:system(cmd) abort
return system(a:cmd)
endf

" TODO: make it pause after output in console mode
func! s:log(msg)
echo a:msg
func! s:log(str) abort
call add(g:vundle_log, '['.strftime("%y%m%d %T").'] '.a:str)
return a:str
endf

0 comments on commit c5809af

Please sign in to comment.