vundle/autoload/vundle/scripts.vim
gmarik 1695316a29 Revert ":BundleInstall is gone for now"
what was I thinking...?!

This reverts commit 035cc6ecba.
2011-03-19 14:11:02 -05:00

44 lines
1.3 KiB
VimL

func! vundle#scripts#all(bang, ...)
let info = ['"Keymap: i - Install bundle; c - Cleanup; r - Refine list']
if a:1== '' " whether refine search string given
call s:display(info + ['"Vim scripts: '], s:load_scripts(a:bang))
else
let matches = filter(s:load_scripts(a:bang), 'v:val =~? "'.escape(a:1,'"').'"')
let @/=a:1
call s:display(info + ['"Search results for: '.a:1], matches)
redraw
endif
endf
func! vundle#scripts#complete(a,c,d)
return join(s:load_scripts(0),"\n")
endf
func! vundle#scripts#install() abort
let line = substitute(substitute(getline('.'), '\s*Bundle\s*','','g'), "'",'','g')
call vundle#installer#install(0, line)
redraw!
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)
pedit `=s:browse`| wincmd P | wincmd H
setl ft=vundle
endf
func! s:fetch_scripts(to)
let temp = tempname()
exec '!curl http://vim-scripts.org/api/scripts.json > '.temp.
\ '&& mkdir -p $(dirname '.a:to.') && mv -f '.temp.' '.a:to
endf
func! s:load_scripts(bang)
let f = expand('$HOME/.vim-vundle/vim-scripts.org.json')
if a:bang || !filereadable(f)
call s:fetch_scripts(f)
endif
return eval(readfile(f, 'b')[0])
endf