From 5582daf79c1678f2527c6bb90af1876ae21afb76 Mon Sep 17 00:00:00 2001 From: xinleibird Date: Tue, 1 Oct 2013 12:42:42 +0800 Subject: [PATCH] add eclim's checker extension, when eclim is running , it can instead of syntastic --- autoload/airline/deprecation.vim | 1 + autoload/airline/extensions.vim | 7 ++++++- autoload/airline/extensions/eclim.vim | 30 +++++++++++++++++++++++++++ autoload/airline/init.vim | 4 ++-- t/init.vim | 1 + 5 files changed, 40 insertions(+), 3 deletions(-) create mode 100644 autoload/airline/extensions/eclim.vim diff --git a/autoload/airline/deprecation.vim b/autoload/airline/deprecation.vim index a39199c8..dd0567fc 100644 --- a/autoload/airline/deprecation.vim +++ b/autoload/airline/deprecation.vim @@ -19,6 +19,7 @@ function! airline#deprecation#check() \ [ 'g:airline_enable_branch', 'g:airline#extensions#branch#enabled' ], \ [ 'g:airline_enable_bufferline', 'g:airline#extensions#bufferline#enabled' ], \ [ 'g:airline_enable_syntastic', 'g:airline#extensions#syntastic#enabled' ], + \ [ 'g:airline_enable_eclim', 'g:airline#extensions#eclim#enabled' ], \ ] for test in tests if exists(test[0]) diff --git a/autoload/airline/extensions.vim b/autoload/airline/extensions.vim index 814318f4..166e1555 100644 --- a/autoload/airline/extensions.vim +++ b/autoload/airline/extensions.vim @@ -181,8 +181,13 @@ function! airline#extensions#load() call airline#extensions#virtualenv#init(s:ext) endif + if (get(g:, 'airline#extensions#eclim#enabled', 1) && get(g:, 'airline_enable_eclim', 1)) + \ && exists(':ProjectCreate') + call airline#extensions#eclim#init(s:ext) + endif + if (get(g:, 'airline#extensions#syntastic#enabled', 1) && get(g:, 'airline_enable_syntastic', 1)) - \ && exists(':SyntasticCheck') + \ && exists(':SyntasticCheck') && !exists('g:eclim_instead_syntastic') call airline#extensions#syntastic#init(s:ext) endif diff --git a/autoload/airline/extensions/eclim.vim b/autoload/airline/extensions/eclim.vim new file mode 100644 index 00000000..e3ebe31f --- /dev/null +++ b/autoload/airline/extensions/eclim.vim @@ -0,0 +1,30 @@ +" MIT License. Copyright (c) 2013 Bailey Ling. +" vim: et ts=2 sts=2 sw=2 +"if !exists('g:eclim_instead_syntastic') +"let g:eclim_instead_syntastic = 0 +"endif + +"if g:eclim_instead_syntastic == 1 +"finish +"endif +if !exists(':ProjectCreate') + finish +endif + +function! airline#extensions#eclim#get_warnings() + let eclimList = eclim#display#signs#GetExisting() + if !empty(eclimList) + let errorsLine = eclimList[0]['line'] + let errorsNumber = len(eclimList) + let errors = "[Warring: line:".string(errorsLine)." (".string(errorsNumber).")]" + return errors.(g:airline_symbols.space) + endif + return '' +endfunction + +function! airline#extensions#eclim#init(ext) + if !exists('g:eclim_instead_syntastic') + let g:eclim_instead_syntastic = 1 + endif + call airline#parts#define_function('eclim', 'airline#extensions#eclim#get_warnings') +endfunction diff --git a/autoload/airline/init.vim b/autoload/airline/init.vim index f5276d4a..98e662e4 100644 --- a/autoload/airline/init.vim +++ b/autoload/airline/init.vim @@ -78,7 +78,7 @@ function! airline#init#bootstrap() call airline#parts#define_raw('file', '%f%m') call airline#parts#define_raw('linenr', (g:airline_symbols.linenr).'%#__accent_bold#%4l%#__restore__#') call airline#parts#define_function('ffenc', 'airline#parts#ffenc') - call airline#parts#define_empty(['hunks', 'branch', 'tagbar', 'syntastic', 'whitespace']) + call airline#parts#define_empty(['hunks', 'branch', 'tagbar', 'syntastic', 'eclim', 'whitespace']) unlet g:airline#init#bootstrapping endfunction @@ -107,7 +107,7 @@ function! airline#init#sections() let g:airline_section_z = airline#section#create(['%3p%%'.spc, 'linenr', ':%3c ']) endif if !exists('g:airline_section_warning') - let g:airline_section_warning = airline#section#create(['syntastic', 'whitespace']) + let g:airline_section_warning = airline#section#create(['syntastic', 'eclim', 'whitespace']) endif endfunction diff --git a/t/init.vim b/t/init.vim index a7d3d2c7..86efe582 100644 --- a/t/init.vim +++ b/t/init.vim @@ -62,6 +62,7 @@ describe 'init sections' Expect airline#parts#get('branch').raw == '' Expect airline#parts#get('tagbar').raw == '' Expect airline#parts#get('syntastic').raw == '' + Expect airline#parts#get('eclim').raw == '' Expect airline#parts#get('whitespace').raw == '' end end