From b2d3764a18d410820b3623067067cd10f5f7f076 Mon Sep 17 00:00:00 2001 From: Dmitri Vereshchagin Date: Sat, 19 Aug 2017 20:54:23 +0300 Subject: Syntaxerl linter feature check (#861) * Add feature check for SyntaxErl linter * Escape SyntaxErl executable path in commands --- ale_linters/erlang/syntaxerl.vim | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) (limited to 'ale_linters/erlang') 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', \}) -- cgit v1.2.3