2018-03-31 10:55:20 -04:00
|
|
|
" Author: kmarc <korondi.mark@gmail.com>
|
2022-11-20 06:21:23 -05:00
|
|
|
" Description: This file adds support for using GNU awk with scripts.
|
2018-03-31 10:55:20 -04:00
|
|
|
|
2018-08-25 12:13:42 -04:00
|
|
|
call ale#Set('awk_gawk_executable', 'gawk')
|
|
|
|
call ale#Set('awk_gawk_options', '')
|
2018-03-31 10:55:20 -04:00
|
|
|
|
|
|
|
function! ale_linters#awk#gawk#GetCommand(buffer) abort
|
|
|
|
" note the --source 'BEGIN ...' is to prevent
|
|
|
|
" gawk from attempting to execute the body of the script
|
|
|
|
" it is linting.
|
2018-08-25 12:13:42 -04:00
|
|
|
return '%e --source ' . ale#Escape('BEGIN { exit } END { exit 1 }')
|
2022-08-08 09:45:56 -04:00
|
|
|
\ . ' --lint'
|
2018-07-19 08:52:53 -04:00
|
|
|
\ . ale#Pad(ale#Var(a:buffer, 'awk_gawk_options'))
|
2022-08-08 09:45:56 -04:00
|
|
|
\ . ' -f %t /dev/null'
|
2018-03-31 10:55:20 -04:00
|
|
|
endfunction
|
|
|
|
|
|
|
|
call ale#linter#Define('awk', {
|
|
|
|
\ 'name': 'gawk',
|
2019-03-08 06:04:56 -05:00
|
|
|
\ 'executable': {b -> ale#Var(b, 'awk_gawk_executable')},
|
|
|
|
\ 'command': function('ale_linters#awk#gawk#GetCommand'),
|
2018-03-31 10:55:20 -04:00
|
|
|
\ 'callback': 'ale#handlers#gawk#HandleGawkFormat',
|
|
|
|
\ 'output_stream': 'both'
|
|
|
|
\})
|