2010-11-26 13:33:17 -05:00
|
|
|
func! vundle#scripts#search(bang,search_str)
|
2010-11-26 17:28:52 -05:00
|
|
|
let matches = filter(s:load_scripts(a:bang), 'v:val =~ "'.escape(a:search_str,'"').'"')
|
2010-11-24 17:15:16 -05:00
|
|
|
let results = map(matches, ' printf("Bundle \"%s\"", v:val) ')
|
2010-11-26 17:14:17 -05:00
|
|
|
call s:display(results, a:search_str)
|
|
|
|
endf
|
|
|
|
|
|
|
|
func! s:display(results,search_str)
|
2010-11-29 17:37:12 -05:00
|
|
|
if !exists('s:buff') | let s:buff = tempname() | endif
|
2010-11-26 17:14:17 -05:00
|
|
|
call writefile(['" Search results for: '.a:search_str] + a:results, s:buff)
|
2010-11-29 17:37:12 -05:00
|
|
|
pedit `=s:buff`
|
|
|
|
wincmd P
|
2010-11-26 13:33:17 -05:00
|
|
|
let @/=a:search_str
|
2010-11-24 16:55:32 -05:00
|
|
|
setlocal hls ft=vim
|
2010-11-24 16:55:05 -05:00
|
|
|
redraw
|
2010-11-02 23:24:55 -04:00
|
|
|
endf
|
|
|
|
|
2010-11-26 17:28:52 -05:00
|
|
|
func! s:fetch_scripts(to)
|
2010-11-02 23:24:55 -04:00
|
|
|
let temp = tempname()
|
2010-11-18 18:13:55 -05:00
|
|
|
exec '!curl http://vim-scripts.org/api/scripts.json > '.temp
|
2010-11-24 17:15:16 -05:00
|
|
|
exec '!mkdir -p $(dirname '.a:to.') && mv -f '.temp.' '.a:to
|
2010-11-02 23:24:55 -04:00
|
|
|
endf
|
|
|
|
|
2010-11-26 17:28:52 -05:00
|
|
|
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)
|
2010-11-02 23:24:55 -04:00
|
|
|
endif
|
2010-11-26 17:28:52 -05:00
|
|
|
return eval(readfile(f, 'b')[0])
|
2010-11-02 23:24:55 -04:00
|
|
|
endf
|