2017-06-08 17:26:21 +00:00
|
|
|
" Author: kmarc <korondi.mark@gmail.com>
|
|
|
|
" Description: This file adds support for using GNU awk with sripts.
|
|
|
|
|
2018-08-02 22:44:12 +00:00
|
|
|
call ale#Set('awk_gawk_executable', 'gawk')
|
|
|
|
call ale#Set('awk_gawk_options', '')
|
2017-06-08 17:26:21 +00:00
|
|
|
|
|
|
|
function! ale_linters#awk#gawk#GetCommand(buffer) abort
|
2018-03-14 17:46:57 +00:00
|
|
|
" note the --source 'BEGIN ...' is to prevent
|
|
|
|
" gawk from attempting to execute the body of the script
|
|
|
|
" it is linting.
|
2018-08-02 22:44:12 +00:00
|
|
|
return '%e --source ' . ale#Escape('BEGIN { exit } END { exit 1 }')
|
2018-07-15 17:24:53 +00:00
|
|
|
\ . ale#Pad(ale#Var(a:buffer, 'awk_gawk_options'))
|
2018-08-02 22:44:12 +00:00
|
|
|
\ . ' -f %t --lint /dev/null'
|
2017-06-08 17:26:21 +00:00
|
|
|
endfunction
|
|
|
|
|
|
|
|
call ale#linter#Define('awk', {
|
|
|
|
\ 'name': 'gawk',
|
2019-02-22 18:05:04 +00:00
|
|
|
\ 'executable': {b -> ale#Var(b, 'awk_gawk_executable')},
|
|
|
|
\ 'command': function('ale_linters#awk#gawk#GetCommand'),
|
2018-03-14 17:46:57 +00:00
|
|
|
\ 'callback': 'ale#handlers#gawk#HandleGawkFormat',
|
2017-06-08 17:26:21 +00:00
|
|
|
\ 'output_stream': 'both'
|
|
|
|
\})
|