From a038016df35c272776a6124640befe067d5bf89b Mon Sep 17 00:00:00 2001 From: gmarik Date: Fri, 5 Aug 2011 10:12:04 -0500 Subject: [PATCH] extract signing into function --- autoload/vundle.vim | 2 ++ autoload/vundle/installer.vim | 18 +++++++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/autoload/vundle.vim b/autoload/vundle.vim index c6541a3..902e70c 100644 --- a/autoload/vundle.vim +++ b/autoload/vundle.vim @@ -27,10 +27,12 @@ com! -nargs=? -bang BundleSearch au Filetype vundle call vundle#scripts#setup_view() au Syntax vim syn keyword vimCommand Bundle +if (has('signs')) sign define VuEr text=! texthl=Error sign define VuAc text=> texthl=Comment sign define VuCu text=. texthl=Comment sign define VuUp text=+ texthl=Comment +endif func! vundle#rc(...) abort diff --git a/autoload/vundle/installer.vim b/autoload/vundle/installer.vim index 79e9138..223b9b5 100644 --- a/autoload/vundle/installer.vim +++ b/autoload/vundle/installer.vim @@ -41,29 +41,37 @@ func! s:display(headers, results) call vundle#scripts#setup_view() endf +func! s:sign(status) + if (!has('signs')) + return + endif + + let markers = {'updated': 'VuUp', 'uptodate': 'VuCu', 'error': 'VuEr', 'active': 'VuAc' } + let marker = markers[a:status] + exe ":sign place ".line('.')." line=".line('.')." name=". marker ." buffer=" . bufnr("%") +endf + func! vundle#installer#install(bang, name) abort if !isdirectory(g:bundle_dir) | call mkdir(g:bundle_dir, 'p') | endif let b = vundle#config#init_bundle(a:name, {}) echo 'Installing '.b.name - exe ":sign place ".line('.')." line=".line('.')." name=VuAc buffer=" . bufnr("$") - + call s:sign('active') sleep 1m let status = s:sync(a:bang, b) + call s:sign(status) + if 'updated' == status echo b.name.' installed' - exe ":sign place ".line('.')." line=".line('.')." name=VuUp buffer=" . bufnr("$") elseif 'uptodate' == status echo b.name.' already installed' - exe ":sign place ".line('.')." line=".line('.')." name=VuCu buffer=" . bufnr("$") elseif 'error' == status echohl Error echo 'Error installing "'.b.name echohl None - exe ":sign place ".line('.')." line=".line('.')." name=VuEr buffer=" . bufnr("$") sleep 1 else throw 'whoops, unknown status:'.status