From 3c33251ee79b80d4d93a0134783eed0ce55b70ef Mon Sep 17 00:00:00 2001 From: Saad Malik Date: Mon, 26 Sep 2016 20:57:51 -0700 Subject: [PATCH] Support for neomake Added support for neomake plugin; similar to syntastic. Shows warning and error counts in the airline statusbar. --- autoload/airline/extensions.vim | 4 ++++ autoload/airline/extensions/neomake.vim | 25 +++++++++++++++++++++++++ autoload/airline/init.vim | 7 ++++--- 3 files changed, 33 insertions(+), 3 deletions(-) create mode 100644 autoload/airline/extensions/neomake.vim diff --git a/autoload/airline/extensions.vim b/autoload/airline/extensions.vim index 9bb42e7..296f7f1 100644 --- a/autoload/airline/extensions.vim +++ b/autoload/airline/extensions.vim @@ -216,6 +216,10 @@ function! airline#extensions#load() call airline#extensions#whitespace#init(s:ext) endif + if (get(g:, 'airline#extensions#neomake#enabled', 1) && exists(':Neomake')) + call airline#extensions#neomake#init(s:ext) + endif + if get(g:, 'airline#extensions#po#enabled', 1) && executable('msgfmt') call airline#extensions#po#init(s:ext) endif diff --git a/autoload/airline/extensions/neomake.vim b/autoload/airline/extensions/neomake.vim new file mode 100644 index 0000000..6587f87 --- /dev/null +++ b/autoload/airline/extensions/neomake.vim @@ -0,0 +1,25 @@ +" vim: et ts=2 sts=2 sw=2 + +if !exists(':Neomake') + finish +endif + +let s:error_symbol = get(g:, 'airline#extensions#neomake#error_symbol', 'E:') +let s:warning_symbol = get(g:, 'airline#extensions#neomake#warning_symbol', 'W:') + +function! airline#extensions#neomake#get_warnings() + let counts = neomake#statusline#LoclistCounts() + let warnings = get(counts, 'W', 0) + return warnings ? s:warning_symbol.warnings : '' +endfunction + +function! airline#extensions#neomake#get_errors() + let counts = neomake#statusline#LoclistCounts() + let errors = get(counts, 'E', 0) + return errors ? s:error_symbol.errors : '' +endfunction + +function! airline#extensions#neomake#init(ext) + call airline#parts#define_function('neomake_warning_count', 'airline#extensions#neomake#get_warnings') + call airline#parts#define_function('neomake_error_count', 'airline#extensions#neomake#get_errors') +endfunction diff --git a/autoload/airline/init.vim b/autoload/airline/init.vim index e2a21eb..253c69a 100644 --- a/autoload/airline/init.vim +++ b/autoload/airline/init.vim @@ -96,7 +96,8 @@ function! airline#init#bootstrap() \ 'accent': 'bold'}) call airline#parts#define_function('ffenc', 'airline#parts#ffenc') call airline#parts#define_empty(['hunks', 'branch', 'obsession', 'tagbar', 'syntastic', - \ 'eclim', 'whitespace','windowswap', 'ycm_error_count', 'ycm_warning_count']) + \ 'eclim', 'whitespace','windowswap', 'ycm_error_count', 'ycm_warning_count', + \ 'neomake_error_count', 'neomake_warning_count']) call airline#parts#define_text('capslock', '') unlet g:airline#init#bootstrapping @@ -140,10 +141,10 @@ function! airline#init#sections() endif endif if !exists('g:airline_section_error') - let g:airline_section_error = airline#section#create(['ycm_error_count', 'syntastic', 'eclim']) + let g:airline_section_error = airline#section#create(['ycm_error_count', 'syntastic', 'eclim', 'neomake_error_count']) endif if !exists('g:airline_section_warning') - let g:airline_section_warning = airline#section#create(['ycm_warning_count', 'whitespace']) + let g:airline_section_warning = airline#section#create(['ycm_warning_count', 'neomake_warning_count', 'whitespace']) endif endfunction