diff --git a/autoload/airline/extensions.vim b/autoload/airline/extensions.vim index 296f7f13..1dee169f 100644 --- a/autoload/airline/extensions.vim +++ b/autoload/airline/extensions.vim @@ -212,6 +212,10 @@ function! airline#extensions#load() call airline#extensions#syntastic#init(s:ext) endif + if (get(g:, 'airline#extensions#ale#enabled', 1) && exists('g:loaded_ale')) + call airline#extensions#ale#init(s:ext) + endif + if get(g:, 'airline#extensions#whitespace#enabled', 1) call airline#extensions#whitespace#init(s:ext) endif diff --git a/autoload/airline/extensions/ale.vim b/autoload/airline/extensions/ale.vim new file mode 100644 index 00000000..84b1b36e --- /dev/null +++ b/autoload/airline/extensions/ale.vim @@ -0,0 +1,36 @@ +" MIT License. Copyright (c) 2013-2016 Bjorn Neergaard. +" vim: et ts=2 sts=2 sw=2 + +if !exists('g:loaded_ale') + finish +endif + +let s:error_symbol = get(g:, 'airline#extensions#ale#error_symbol', 'E:') +let s:warning_symbol = get(g:, 'airline#extensions#ale#warning_symbol', 'W:') + +function! s:count(index) + let l:buf = bufnr('%') + let l:count = ale#statusline#Count(l:buf) + if type(l:count) ==# type(0) + let l:count = 0 + else + let l:count = l:count[a:index] + endif + + return l:count +endfunction + +function! airline#extensions#ale#get_errors() + let l:count = s:count(0) + return l:count ? s:error_symbol . l:count : '' +endfunction + +function! airline#extensions#ale#get_warnings() + let l:count = s:count(1) + return l:count ? s:warning_symbol . l:count : '' +endfunction + +function! airline#extensions#ale#init(ext) + call airline#parts#define_function('ale_error_count', 'airline#extensions#ale#get_errors') + call airline#parts#define_function('ale_warning_count', 'airline#extensions#ale#get_warnings') +endfunction diff --git a/autoload/airline/init.vim b/autoload/airline/init.vim index 40ec79ec..93cd1131 100644 --- a/autoload/airline/init.vim +++ b/autoload/airline/init.vim @@ -102,7 +102,7 @@ function! airline#init#bootstrap() 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', - \ 'neomake_error_count', 'neomake_warning_count']) + \ 'neomake_error_count', 'neomake_warning_count', 'ale_error_count', 'ale_warning_count']) call airline#parts#define_text('capslock', '') unlet g:airline#init#bootstrapping @@ -146,9 +146,9 @@ 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', 'neomake_error_count']) + let g:airline_section_error = airline#section#create(['ycm_error_count', 'syntastic', 'eclim', 'neomake_error_count', 'ale_error_count']) endif if !exists('g:airline_section_warning') - let g:airline_section_warning = airline#section#create(['ycm_warning_count', 'neomake_warning_count', 'whitespace']) + let g:airline_section_warning = airline#section#create(['ycm_warning_count', 'neomake_warning_count', 'ale_warning_count', 'whitespace']) endif endfunction