diff options
author | Dmitri Vereshchagin <dmitri.vereshchagin@gmail.com> | 2017-08-19 20:54:23 +0300 |
---|---|---|
committer | w0rp <w0rp@users.noreply.github.com> | 2017-08-19 18:54:23 +0100 |
commit | b2d3764a18d410820b3623067067cd10f5f7f076 (patch) | |
tree | 338a8e975b432b98cf7a4f93ad5a416c07cd99e9 /ale_linters/erlang | |
parent | 20e64fbae092e7307c4f01d82fa0e0082c3bb1cb (diff) | |
download | ale-b2d3764a18d410820b3623067067cd10f5f7f076.zip |
Syntaxerl linter feature check (#861)
* Add feature check for SyntaxErl linter
* Escape SyntaxErl executable path in commands
Diffstat (limited to 'ale_linters/erlang')
-rw-r--r-- | ale_linters/erlang/syntaxerl.vim | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/ale_linters/erlang/syntaxerl.vim b/ale_linters/erlang/syntaxerl.vim index e7d006b4..46ecdcb7 100644 --- a/ale_linters/erlang/syntaxerl.vim +++ b/ale_linters/erlang/syntaxerl.vim @@ -2,7 +2,6 @@ " Description: SyntaxErl linter for Erlang files call ale#Set('erlang_syntaxerl_executable', 'syntaxerl') -call ale#Set('erlang_syntaxerl_use_basename', 0) function! ale_linters#erlang#syntaxerl#GetExecutable(buffer) abort @@ -10,14 +9,15 @@ function! ale_linters#erlang#syntaxerl#GetExecutable(buffer) abort endfunction -function! ale_linters#erlang#syntaxerl#GetCommand(buffer) abort - let l:base_options = ale#Var(a:buffer, 'erlang_syntaxerl_use_basename') - \ ? ' -b %s' - \ : '' +function! ale_linters#erlang#syntaxerl#FeatureCheck(buffer) abort + return s:GetEscapedExecutable(a:buffer) . ' -h' +endfunction + + +function! ale_linters#erlang#syntaxerl#GetCommand(buffer, output) abort + let l:use_b_option = match(a:output, '\C\V-b, --base\>') > -1 - return ale_linters#erlang#syntaxerl#GetExecutable(a:buffer) - \ . l:base_options - \ . ' %t' + return s:GetEscapedExecutable(a:buffer) . (l:use_b_option ? ' -b %s %t' : ' %t') endfunction @@ -37,9 +37,17 @@ function! ale_linters#erlang#syntaxerl#Handle(buffer, lines) abort endfunction +function! s:GetEscapedExecutable(buffer) abort + return ale#Escape(ale_linters#erlang#syntaxerl#GetExecutable(a:buffer)) +endfunction + + call ale#linter#Define('erlang', { \ 'name': 'syntaxerl', \ 'executable_callback': 'ale_linters#erlang#syntaxerl#GetExecutable', -\ 'command_callback': 'ale_linters#erlang#syntaxerl#GetCommand', +\ 'command_chain': [ +\ {'callback': 'ale_linters#erlang#syntaxerl#FeatureCheck'}, +\ {'callback': 'ale_linters#erlang#syntaxerl#GetCommand'}, +\ ], \ 'callback': 'ale_linters#erlang#syntaxerl#Handle', \}) |