diff options
author | w0rp <devw0rp@gmail.com> | 2019-06-03 23:40:22 +0100 |
---|---|---|
committer | w0rp <devw0rp@gmail.com> | 2019-06-03 23:40:22 +0100 |
commit | eb6015c6fd43d1630046556b2598e8c52c203e6a (patch) | |
tree | 443db3bb16d99f0bfe5e97f300488ca020cc81a8 /ale_linters/java | |
parent | 4496c9b3c12874477dc1971b3cb841f1d5f20d98 (diff) | |
download | ale-eb6015c6fd43d1630046556b2598e8c52c203e6a.zip |
#2542 - Improve checkstyle project configuration
Diffstat (limited to 'ale_linters/java')
-rw-r--r-- | ale_linters/java/checkstyle.vim | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/ale_linters/java/checkstyle.vim b/ale_linters/java/checkstyle.vim index cc93ee8a..ee3ca7a3 100644 --- a/ale_linters/java/checkstyle.vim +++ b/ale_linters/java/checkstyle.vim @@ -1,6 +1,10 @@ " Author: Devon Meunier <devon.meunier@gmail.com> " Description: checkstyle for Java files +call ale#Set('java_checkstyle_executable', 'checkstyle') +call ale#Set('java_checkstyle_config', 'google_checks.xml') +call ale#Set('java_checkstyle_options', '') + function! ale_linters#java#checkstyle#Handle(buffer, lines) abort let l:output = [] @@ -36,18 +40,21 @@ function! ale_linters#java#checkstyle#Handle(buffer, lines) abort endfunction function! ale_linters#java#checkstyle#GetCommand(buffer) abort - return 'checkstyle ' - \ . ale#Var(a:buffer, 'java_checkstyle_options') + let l:options = ale#Var(a:buffer, 'java_checkstyle_options') + let l:config_option = ale#Var(a:buffer, 'java_checkstyle_config') + let l:config = l:options !~# '\v(^| )-c' && !empty(l:config_option) + \ ? ale#path#FindNearestFile(a:buffer, l:config_option) + \ : '' + + return '%e' + \ . ale#Pad(l:options) + \ . (!empty(l:config) ? ' -c ' . ale#Escape(l:config) : '') \ . ' %s' endfunction -if !exists('g:ale_java_checkstyle_options') - let g:ale_java_checkstyle_options = '-c /google_checks.xml' -endif - call ale#linter#Define('java', { \ 'name': 'checkstyle', -\ 'executable': 'checkstyle', +\ 'executable': {b -> ale#Var(b, 'java_checkstyle_executable')}, \ 'command': function('ale_linters#java#checkstyle#GetCommand'), \ 'callback': 'ale_linters#java#checkstyle#Handle', \ 'lint_file': 1, |