From b8c1b26f0ed49922e9101e8e1444e9b95321abcf Mon Sep 17 00:00:00 2001 From: Christian Brabandt Date: Thu, 21 Apr 2016 09:11:22 +0200 Subject: [PATCH] don't throw error if bufferline is not installed airline#extensions#load() tries to load all extensions, the user has specified in g:airline_extensions. However, if e.g. bufferline is requested to be loaded, but is not installed, it will throw an error E117: Unknown function: airline#extensions#bufferline#init Therefore, catch E117 and show a warning. closes #1127 --- autoload/airline/extensions.vim | 6 +++++- autoload/airline/util.vim | 6 ++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/autoload/airline/extensions.vim b/autoload/airline/extensions.vim index 2970dc8e..5a499536 100644 --- a/autoload/airline/extensions.vim +++ b/autoload/airline/extensions.vim @@ -123,7 +123,11 @@ function! airline#extensions#load() if exists('g:airline_extensions') for ext in g:airline_extensions - call airline#extensions#{ext}#init(s:ext) + try + call airline#extensions#{ext}#init(s:ext) + catch /^Vim\%((\a\+)\)\=:E117/ " E117, function does not exist + call airline#util#warning("Extension '".ext."' not installed, ignoring!") + endtry endfor return endif diff --git a/autoload/airline/util.vim b/autoload/airline/util.vim index 65cf9068..f4525516 100644 --- a/autoload/airline/util.vim +++ b/autoload/airline/util.vim @@ -19,6 +19,12 @@ function! airline#util#append(text, minwidth) return empty(a:text) ? '' : prefix.g:airline_left_alt_sep.s:spc.a:text endfunction +function! airline#util#warning(msg) + echohl WarningMsg + echomsg "airline: ".a:msg + echohl Normal +endfunction + function! airline#util#prepend(text, minwidth) if a:minwidth > 0 && winwidth(0) < a:minwidth return ''