#860 Only enable the new option for setting the original filename for SyntaxErl if an option is on in ALE

This commit is contained in:
w0rp 2017-08-19 15:48:29 +01:00
parent f8de08faf0
commit 20e64fbae0
3 changed files with 41 additions and 9 deletions

View File

@ -2,6 +2,7 @@
" Description: SyntaxErl linter for Erlang files " Description: SyntaxErl linter for Erlang files
call ale#Set('erlang_syntaxerl_executable', 'syntaxerl') call ale#Set('erlang_syntaxerl_executable', 'syntaxerl')
call ale#Set('erlang_syntaxerl_use_basename', 0)
function! ale_linters#erlang#syntaxerl#GetExecutable(buffer) abort function! ale_linters#erlang#syntaxerl#GetExecutable(buffer) abort
@ -10,7 +11,13 @@ endfunction
function! ale_linters#erlang#syntaxerl#GetCommand(buffer) abort function! ale_linters#erlang#syntaxerl#GetCommand(buffer) abort
return ale_linters#erlang#syntaxerl#GetExecutable(a:buffer) . ' -b %s %t' let l:base_options = ale#Var(a:buffer, 'erlang_syntaxerl_use_basename')
\ ? ' -b %s'
\ : ''
return ale_linters#erlang#syntaxerl#GetExecutable(a:buffer)
\ . l:base_options
\ . ' %t'
endfunction endfunction

View File

@ -25,5 +25,17 @@ g:ale_erlang_syntaxerl_executable *g:ale_erlang_syntaxerl_executable*
This variable can be changed to specify the syntaxerl executable. This variable can be changed to specify the syntaxerl executable.
g:ale_erlang_syntaxerl_use_basename *g:ale_erlang_syntaxerl_use_basename*
*b:ale_erlang_syntaxerl_use_basename*
Type: |Number|
Default: `0`
When set to `1`, the `-b` argument for telling SyntaxErl about the path to the
file being checked will be used. The argument is only available in newer
versions of SyntaxErl.
This option will be enabled by default in future.
=============================================================================== ===============================================================================
vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:

View File

@ -1,13 +1,20 @@
Before: Before:
Save g:ale_erlang_syntaxerl_executable Save g:ale_erlang_syntaxerl_executable
unlet! g:ale_erlang_syntaxerl_executable b:ale_erlang_syntaxerl_executable Save g:ale_erlang_syntaxerl_use_basename
unlet! g:ale_erlang_syntaxerl_executable
unlet! b:ale_erlang_syntaxerl_executable
unlet! b:ale_erlang_syntaxerl_use_basename
runtime ale_linters/erlang/syntaxerl.vim runtime ale_linters/erlang/syntaxerl.vim
After: After:
call ale#linter#Reset() Restore
Restore g:ale_erlang_syntaxerl_executable
Execute (Get SyntaxErl executable): call ale#linter#Reset()
Execute (The SyntaxErl executable should be correct):
AssertEqual 'syntaxerl', ale_linters#erlang#syntaxerl#GetExecutable(bufnr('')) AssertEqual 'syntaxerl', ale_linters#erlang#syntaxerl#GetExecutable(bufnr(''))
let g:ale_erlang_syntaxerl_executable = '/some/other/syntaxerl' let g:ale_erlang_syntaxerl_executable = '/some/other/syntaxerl'
@ -16,11 +23,17 @@ Execute (Get SyntaxErl executable):
let b:ale_erlang_syntaxerl_executable = '/yet/another/syntaxerl' let b:ale_erlang_syntaxerl_executable = '/yet/another/syntaxerl'
AssertEqual '/yet/another/syntaxerl', ale_linters#erlang#syntaxerl#GetExecutable(bufnr('')) AssertEqual '/yet/another/syntaxerl', ale_linters#erlang#syntaxerl#GetExecutable(bufnr(''))
Execute (Get SyntaxErl command line): Execute (The default SyntaxErl command should be correct):
AssertEqual 'syntaxerl -b %s %t', ale_linters#erlang#syntaxerl#GetCommand(bufnr('')) AssertEqual 'syntaxerl %t', ale_linters#erlang#syntaxerl#GetCommand(bufnr(''))
Execute (The executable name should be used in the command):
let g:ale_erlang_syntaxerl_executable = '/some/other/syntaxerl' let g:ale_erlang_syntaxerl_executable = '/some/other/syntaxerl'
AssertEqual '/some/other/syntaxerl -b %s %t', ale_linters#erlang#syntaxerl#GetCommand(bufnr('')) AssertEqual '/some/other/syntaxerl %t', ale_linters#erlang#syntaxerl#GetCommand(bufnr(''))
let b:ale_erlang_syntaxerl_executable = '/yet/another/syntaxerl' let b:ale_erlang_syntaxerl_executable = '/yet/another/syntaxerl'
AssertEqual '/yet/another/syntaxerl -b %s %t', ale_linters#erlang#syntaxerl#GetCommand(bufnr('')) AssertEqual '/yet/another/syntaxerl %t', ale_linters#erlang#syntaxerl#GetCommand(bufnr(''))
Execute (The basename option should be set when the option is on):
let b:ale_erlang_syntaxerl_use_basename = 1
AssertEqual 'syntaxerl -b %s %t', ale_linters#erlang#syntaxerl#GetCommand(bufnr(''))