2017-06-08 13:26:21 -04:00
|
|
|
" Author: kmarc <korondi.mark@gmail.com>
|
|
|
|
" Description: This file adds support for using GNU awk with sripts.
|
|
|
|
|
|
|
|
let g:ale_awk_gawk_executable =
|
|
|
|
\ get(g:, 'ale_awk_gawk_executable', 'gawk')
|
|
|
|
|
|
|
|
let g:ale_awk_gawk_options =
|
|
|
|
\ get(g:, 'ale_awk_gawk_options', '')
|
|
|
|
|
|
|
|
function! ale_linters#awk#gawk#GetExecutable(buffer) abort
|
|
|
|
return ale#Var(a:buffer, 'awk_gawk_executable')
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
function! ale_linters#awk#gawk#GetCommand(buffer) abort
|
2018-03-14 13:46:57 -04:00
|
|
|
" note the --source 'BEGIN ...' is to prevent
|
|
|
|
" gawk from attempting to execute the body of the script
|
|
|
|
" it is linting.
|
2017-06-08 13:26:21 -04:00
|
|
|
return ale_linters#awk#gawk#GetExecutable(a:buffer)
|
2018-03-14 13:46:57 -04:00
|
|
|
\ . " --source 'BEGIN { exit } END { exit 1 }'"
|
2017-06-08 13:26:21 -04:00
|
|
|
\ . ' ' . ale#Var(a:buffer, 'awk_gawk_options')
|
|
|
|
\ . ' ' . '-f %t --lint /dev/null'
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
call ale#linter#Define('awk', {
|
|
|
|
\ 'name': 'gawk',
|
|
|
|
\ 'executable_callback': 'ale_linters#awk#gawk#GetExecutable',
|
|
|
|
\ 'command_callback': 'ale_linters#awk#gawk#GetCommand',
|
2018-03-14 13:46:57 -04:00
|
|
|
\ 'callback': 'ale#handlers#gawk#HandleGawkFormat',
|
2017-06-08 13:26:21 -04:00
|
|
|
\ 'output_stream': 'both'
|
|
|
|
\})
|