mirror of https://github.com/dense-analysis/ale
Merge pull request #3531 from pinicarus/custom-erlc-executable
Custom erlc executable
This commit is contained in:
commit
012348582c
|
@ -1,14 +1,22 @@
|
|||
" Author: Magnus Ottenklinger - https://github.com/evnu
|
||||
|
||||
let g:ale_erlang_erlc_executable = get(g:, 'ale_erlang_erlc_executable', 'erlc')
|
||||
let g:ale_erlang_erlc_options = get(g:, 'ale_erlang_erlc_options', '')
|
||||
|
||||
function! ale_linters#erlang#erlc#GetExecutable(buffer) abort
|
||||
return ale#Var(a:buffer, 'erlang_erlc_executable')
|
||||
endfunction
|
||||
|
||||
function! ale_linters#erlang#erlc#GetCommand(buffer) abort
|
||||
let l:output_file = ale#util#Tempname()
|
||||
call ale#command#ManageFile(a:buffer, l:output_file)
|
||||
|
||||
return 'erlc -o ' . ale#Escape(l:output_file)
|
||||
let l:command = ale#Escape(ale_linters#erlang#erlc#GetExecutable(a:buffer))
|
||||
\ . ' -o ' . ale#Escape(l:output_file)
|
||||
\ . ' ' . ale#Var(a:buffer, 'erlang_erlc_options')
|
||||
\ . ' %t'
|
||||
|
||||
return l:command
|
||||
endfunction
|
||||
|
||||
function! ale_linters#erlang#erlc#Handle(buffer, lines) abort
|
||||
|
@ -90,7 +98,7 @@ endfunction
|
|||
|
||||
call ale#linter#Define('erlang', {
|
||||
\ 'name': 'erlc',
|
||||
\ 'executable': 'erlc',
|
||||
\ 'executable': function('ale_linters#erlang#erlc#GetExecutable'),
|
||||
\ 'command': function('ale_linters#erlang#erlc#GetCommand'),
|
||||
\ 'callback': 'ale_linters#erlang#erlc#Handle',
|
||||
\})
|
||||
|
|
|
@ -46,6 +46,14 @@ g:ale_erlang_elvis_executable *g:ale_erlang_elvis_executable*
|
|||
-------------------------------------------------------------------------------
|
||||
erlc *ale-erlang-erlc*
|
||||
|
||||
g:ale_erlang_erlc_executable *g:ale_erlang_erlc_executable*
|
||||
*b:ale_erlang_erlc_executable*
|
||||
Type: |String|
|
||||
Default: `'erlc'`
|
||||
|
||||
This variable can be changed to specify the erlc executable.
|
||||
|
||||
|
||||
g:ale_erlang_erlc_options *g:ale_erlang_erlc_options*
|
||||
*b:ale_erlang_erlc_options*
|
||||
Type: |String|
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
Before:
|
||||
call ale#assert#SetUpLinterTest('erlang', 'erlc')
|
||||
|
||||
After:
|
||||
call ale#assert#TearDownLinterTest()
|
||||
|
||||
Execute(The default command should be correct.):
|
||||
let g:cmd = ale_linters#erlang#erlc#GetCommand(bufnr(''))
|
||||
let g:regex = 'erlc.\+-o.\+%t'
|
||||
let g:matched = match(g:cmd, g:regex)
|
||||
|
||||
" match returns -1 if not found
|
||||
AssertNotEqual
|
||||
\ g:matched,
|
||||
\ -1,
|
||||
\ 'Command error: expected [' . g:cmd . '] to match [' . g:regex . ']'
|
||||
|
||||
Execute(The command should accept configured executable.):
|
||||
let b:ale_erlang_erlc_executable = '/usr/bin/erlc'
|
||||
let g:cmd = ale_linters#erlang#erlc#GetCommand(bufnr(''))
|
||||
let g:regex = '/usr/bin/erlc.\+-o.\+%t'
|
||||
let g:matched = match(g:cmd, g:regex)
|
||||
|
||||
" match returns -1 if not found
|
||||
AssertNotEqual
|
||||
\ g:matched,
|
||||
\ -1,
|
||||
\ 'Command error: expected [' . g:cmd . '] to match [' . g:regex . ']'
|
||||
|
||||
Execute(The command should accept configured options.):
|
||||
let b:ale_erlang_erlc_options = '-I include'
|
||||
let g:cmd = ale_linters#erlang#erlc#GetCommand(bufnr(''))
|
||||
let g:regex = 'erlc.\+-o.\+-I include.\+%t'
|
||||
let g:matched = match(g:cmd, g:regex)
|
||||
|
||||
" match returns -1 if not found
|
||||
AssertNotEqual
|
||||
\ g:matched,
|
||||
\ -1,
|
||||
\ 'Command error: expected [' . g:cmd . '] to match [' . g:regex . ']'
|
Loading…
Reference in New Issue