diff options
author | w0rp <devw0rp@gmail.com> | 2017-08-19 15:48:29 +0100 |
---|---|---|
committer | w0rp <devw0rp@gmail.com> | 2017-08-19 15:48:29 +0100 |
commit | 20e64fbae092e7307c4f01d82fa0e0082c3bb1cb (patch) | |
tree | 386644e3d48afbd9b8af8e8de4c100cb93df02e6 | |
parent | f8de08faf0c23ac4b76e610f685dcf6c3dfdf180 (diff) | |
download | ale-20e64fbae092e7307c4f01d82fa0e0082c3bb1cb.zip |
#860 Only enable the new option for setting the original filename for SyntaxErl if an option is on in ALE
-rw-r--r-- | ale_linters/erlang/syntaxerl.vim | 9 | ||||
-rw-r--r-- | doc/ale-erlang.txt | 12 | ||||
-rw-r--r-- | test/command_callback/test_erlang_syntaxerl_command_callback.vader | 27 |
3 files changed, 40 insertions, 8 deletions
diff --git a/ale_linters/erlang/syntaxerl.vim b/ale_linters/erlang/syntaxerl.vim index 7a94856a..e7d006b4 100644 --- a/ale_linters/erlang/syntaxerl.vim +++ b/ale_linters/erlang/syntaxerl.vim @@ -2,6 +2,7 @@ " 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,7 +11,13 @@ endfunction 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 diff --git a/doc/ale-erlang.txt b/doc/ale-erlang.txt index ad3c1e5a..72d40237 100644 --- a/doc/ale-erlang.txt +++ b/doc/ale-erlang.txt @@ -25,5 +25,17 @@ g:ale_erlang_syntaxerl_executable *g:ale_erlang_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: diff --git a/test/command_callback/test_erlang_syntaxerl_command_callback.vader b/test/command_callback/test_erlang_syntaxerl_command_callback.vader index 800aaf3f..130becf6 100644 --- a/test/command_callback/test_erlang_syntaxerl_command_callback.vader +++ b/test/command_callback/test_erlang_syntaxerl_command_callback.vader @@ -1,13 +1,20 @@ Before: 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 After: + Restore + call ale#linter#Reset() - Restore g:ale_erlang_syntaxerl_executable -Execute (Get SyntaxErl executable): + +Execute (The SyntaxErl executable should be correct): AssertEqual 'syntaxerl', ale_linters#erlang#syntaxerl#GetExecutable(bufnr('')) 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' AssertEqual '/yet/another/syntaxerl', ale_linters#erlang#syntaxerl#GetExecutable(bufnr('')) -Execute (Get SyntaxErl command line): - AssertEqual 'syntaxerl -b %s %t', ale_linters#erlang#syntaxerl#GetCommand(bufnr('')) +Execute (The default SyntaxErl command should be correct): + 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' - 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' - 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('')) |