From 3f13edf6aa4b9e40bac38436603e2df3df1c73c5 Mon Sep 17 00:00:00 2001 From: gmarik Date: Sat, 19 Mar 2011 02:54:35 -0500 Subject: [PATCH] refactor. simple UI to install individual scripts --- autoload/vundle.vim | 3 +++ autoload/vundle/scripts.vim | 27 ++++++++++++++++++--------- ftplugin/vundle.vim | 10 ++++++++++ 3 files changed, 31 insertions(+), 9 deletions(-) create mode 100644 ftplugin/vundle.vim diff --git a/autoload/vundle.vim b/autoload/vundle.vim index a2c1c38..5e4c08e 100644 --- a/autoload/vundle.vim +++ b/autoload/vundle.vim @@ -19,6 +19,9 @@ com! -nargs=0 BundleDocs com! -nargs=+ -bang BundleSearch \ silent call vundle#scripts#search('!' == '', ) +com! -nargs=0 Vundle + \ call vundle#scripts#browse() + com! -nargs=0 VundleLog \ silent pedit `=g:vundle_log` diff --git a/autoload/vundle/scripts.vim b/autoload/vundle/scripts.vim index 9414087..c3c808f 100644 --- a/autoload/vundle/scripts.vim +++ b/autoload/vundle/scripts.vim @@ -1,23 +1,32 @@ func! vundle#scripts#search(bang,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) ') - call s:display(reverse(results), a:search_str) + call s:display(['" Search results for: '.a:search_str], matches) + let @/=a:search_str + redraw +endf + +func! vundle#scripts#browse() + call s:display(['" Vim scripts: '], s:load_scripts(0)) endf func! vundle#scripts#complete(a,c,d) return join(s:load_scripts(0),"\n") endf -func! s:display(results,search_str) - if !exists('s:buff') | let s:buff = tempname() | endif - call writefile(['" Search results for: '.a:search_str] + a:results, s:buff) - pedit `=s:buff` - wincmd P - let @/=a:search_str - setlocal hls ignorecase ft=vim +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 diff --git a/ftplugin/vundle.vim b/ftplugin/vundle.vim new file mode 100644 index 0000000..c968097 --- /dev/null +++ b/ftplugin/vundle.vim @@ -0,0 +1,10 @@ +setl hls ro noma ignorecase + +set syntax=vim + +syn keyword vimCommand Bundle + +nnoremap :call vundle#scripts#install() +nnoremap s :BundleSearch +nnoremap c :BundleClean +nnoremap C :BundleClean!