This commit is contained in:
gmarik 2010-11-26 16:28:52 -06:00
parent 5632996548
commit ef641633b5

View File

@ -1,5 +1,5 @@
func! vundle#scripts#search(bang,search_str) func! vundle#scripts#search(bang,search_str)
let matches = filter(eval(vundle#scripts#read(a:bang)), 'v:val =~ "'.escape(a:search_str,'"').'"') let matches = filter(s:load_scripts(a:bang), 'v:val =~ "'.escape(a:search_str,'"').'"')
let results = map(matches, ' printf("Bundle \"%s\"", v:val) ') let results = map(matches, ' printf("Bundle \"%s\"", v:val) ')
call s:display(results, a:search_str) call s:display(results, a:search_str)
endf endf
@ -16,16 +16,16 @@ func! s:display(results,search_str)
redraw redraw
endf endf
func! vundle#scripts#fetch(to) func! s:fetch_scripts(to)
let temp = tempname() let temp = tempname()
exec '!curl http://vim-scripts.org/api/scripts.json > '.temp exec '!curl http://vim-scripts.org/api/scripts.json > '.temp
exec '!mkdir -p $(dirname '.a:to.') && mv -f '.temp.' '.a:to exec '!mkdir -p $(dirname '.a:to.') && mv -f '.temp.' '.a:to
endf endf
func! vundle#scripts#read(bang) func! s:load_scripts(bang)
let scripts_file = expand('$HOME/.vim-vundle/vim-scripts.org.json') let f = expand('$HOME/.vim-vundle/vim-scripts.org.json')
if '!' == a:bang || !filereadable(scripts_file) if '!' == a:bang || !filereadable(f)
call vundle#scripts#fetch(scripts_file) call s:fetch_scripts(f)
endif endif
return readfile(scripts_file, 'b')[0] return eval(readfile(f, 'b')[0])
endf endf