This commit is contained in:
gmarik 2010-11-24 16:15:16 -06:00
parent e7995e04d5
commit 7f7b3f1097
2 changed files with 11 additions and 30 deletions

View File

@ -7,7 +7,7 @@ com! -nargs=+ Bundle call vundle#add_bundle(<args>)
com! -nargs=0 BundleInstall call vundle#install_bundles()
com! -nargs=0 BundleDocs call vundle#helptagify_bundles()
com! -nargs=* BundleSearch call vundle#scripts#search(<q-args>)
com! -nargs=* BundleSearch silent call vundle#scripts#search(<q-args>)
func! vundle#rc()
let g:bundle_dir = expand('$HOME/.vim/bundle/')
@ -25,10 +25,7 @@ endf
func! vundle#init_bundle(arg, opts)
let bundle = a:opts | let arg = a:arg
if arg =~ '^\s*\d\+\s*$' || type(arg) == type(42) " script id
let bundle.name = vundle#scripts#find(arg)
let bundle.uri = vundle#script_uri(bundle.name)
elseif arg =~ '^\s*\(git@\|git://\)\S\+' || arg =~ 'https\?://' || arg =~ '\.git\*$'
if arg =~ '^\s*\(git@\|git://\)\S\+' || arg =~ 'https\?://' || arg =~ '\.git\*$'
let bundle.uri = arg
let bundle.name = substitute(split(bundle.uri,'\/')[-1], '\.git\s*$','','i')
else

View File

@ -1,40 +1,24 @@
func! vundle#scripts#search(...)
let matches = map(vundle#scripts#lookup(a:1), ' printf("Bundle \"%s\"", v:val) ')
let matches = filter(eval(vundle#scripts#read()), 'v:val =~ "'.escape(a:1,'"').'"')
let results = map(matches, ' printf("Bundle \"%s\"", v:val) ')
let temp = tempname()
call writefile(matches, temp)
call writefile(results, temp)
exec 'sp '.temp
let @/=a:1
setlocal hls ft=vim
redraw
endf
func! vundle#scripts#lookup(term)
return filter(vundle#scripts#load(), 'v:val =~ "'.escape(a:term,'"').'"')
endf
func! vundle#scripts#fetch()
let to = g:vundle_scripts_file
func! vundle#scripts#fetch(to)
let temp = tempname()
exec '!curl http://vim-scripts.org/api/scripts.json > '.temp
exec '!mkdir -p $(dirname '.to.') && mv -f '.temp.' '.to
return to
exec '!mkdir -p $(dirname '.a:to.') && mv -f '.temp.' '.a:to
endf
func! vundle#scripts#read()
if !filereadable(g:vundle_scripts_file)
call vundle#scripts#fetch()
let scripts_file = expand('$HOME/.vim-vundle/vim-scripts.org.json')
if !filereadable(scripts_file)
call vundle#scripts#fetch(scripts_file)
endif
return readfile(g:vundle_scripts_file, 'b')[0]
endf
func! vundle#scripts#load()
let g:vundle_scripts_file = expand('$HOME/.vim-vundle/vim-scripts.org.json')
let g:vundle_scripts = eval(vundle#scripts#read())
return g:vundle_scripts
endf
func! vundle#scripts#find(id)
let scripts = vundle#scripts#load()
return scripts[a:id]
return readfile(scripts_file, 'b')[0]
endf