extract common code

This commit is contained in:
gmarik 2011-08-05 23:45:55 -05:00
parent b9226caacb
commit 57474f97a7
2 changed files with 9 additions and 31 deletions

View File

@ -4,7 +4,7 @@ func! vundle#installer#new(bang, ...) abort
\ map(copy(a:000), 'vundle#config#init_bundle(v:val, {})') \ map(copy(a:000), 'vundle#config#init_bundle(v:val, {})')
let names = map(copy(bundles), 'v:val.name_spec') let names = map(copy(bundles), 'v:val.name_spec')
call s:display(['" Installing'], names) call vundle#scripts#view('Installer',['" Installing'], names)
exec ":1" exec ":1"
redraw! redraw!
@ -23,24 +23,6 @@ func! vundle#installer#new(bang, ...) abort
echo 'Done! Helptags: '.len(helptags).' bundles processed' echo 'Done! Helptags: '.len(helptags).' bundles processed'
endf endf
func! s:display(headers, results)
if exists('g:vundle_view')
exec g:vundle_view.'bd!'
endif
let results = map(a:results, ' printf("Bundle ' ."'%s'".'", v:val) ')
silent pedit [Vundle] installer
wincmd P | wincmd H
let g:vundle_view = bufnr('%')
call append(0, a:headers + results)
setl ft=vundle
call vundle#scripts#setup_view()
endf
func! s:sign(status) func! s:sign(status)
if (!has('signs')) if (!has('signs'))
return return

View File

@ -1,18 +1,14 @@
func! vundle#scripts#all(bang, ...) func! vundle#scripts#all(bang, ...)
let b:match = '' let b:match = ''
let info = ['"Keymap: i - Install bundle; c - Cleanup; r - Refine list; R - Reload list'] let info = ['"Keymap: i - Install bundle; c - Cleanup; r - Refine list; R - Reload list']
if a:1== '' " whether refine search string given
let matches = s:load_scripts(a:bang) let matches = s:load_scripts(a:bang)
call s:display(info, matches) if !empty(a:1)
else
let matches = filter(s:load_scripts(a:bang), 'v:val =~? "'.escape(a:1,'"').'"') let matches = filter(s:load_scripts(a:bang), 'v:val =~? "'.escape(a:1,'"').'"')
call s:display(info + ['"Search results for: '.a:1], matches) let info += ['"Search results for: '.a:1]
if &hls " TODO: highlight matches
" TODO: search doesn't get highlighted for me
let @/=a:1
endif
let b:match = a:1 let b:match = a:1
endif endif
call vundle#scripts#view('search',info, reverse(matches))
redraw! redraw!
echo len(matches).' bundles found' echo len(matches).' bundles found'
endf endf
@ -56,13 +52,13 @@ func! s:view_log()
wincmd P | wincmd H wincmd P | wincmd H
endf endf
func! s:display(headers, results) func! vundle#scripts#view(title, headers, results)
if exists('g:vundle_view') if exists('g:vundle_view')
exec g:vundle_view.'bd!' exec g:vundle_view.'bd!'
endif endif
let results = reverse(map(a:results, ' printf("Bundle ' ."'%s'".'", v:val) ')) let results = map(a:results, ' printf("Bundle ' ."'%s'".'", v:val) ')
silent pedit [Vundle] search exec 'silent pedit [Vundle] '.a:title
wincmd P | wincmd H wincmd P | wincmd H