#2132 - Implement deferred executable string handling for linters

This commit is contained in:
w0rp
2019-02-12 18:05:33 +00:00
parent bf196ba17c
commit 926ad47a49
7 changed files with 116 additions and 31 deletions

View File

@@ -120,7 +120,8 @@ function! ale#linter#PreProcess(filetype, linter) abort
let l:obj.executable = a:linter.executable
if type(l:obj.executable) isnot v:t_string
throw '`executable` must be a string if defined'
\&& type(l:obj.executable) isnot v:t_func
throw '`executable` must be a String or Function if defined'
endif
else
throw 'Either `executable` or `executable_callback` must be defined'
@@ -476,9 +477,13 @@ endfunction
" Given a buffer and linter, get the executable String for the linter.
function! ale#linter#GetExecutable(buffer, linter) abort
return has_key(a:linter, 'executable_callback')
\ ? ale#util#GetFunction(a:linter.executable_callback)(a:buffer)
let l:Executable = has_key(a:linter, 'executable_callback')
\ ? function(a:linter.executable_callback)
\ : a:linter.executable
return type(l:Executable) is v:t_func
\ ? l:Executable(a:buffer)
\ : l:Executable
endfunction
" Given a buffer and linter, get the command String for the linter.