diff options
author | w0rp <devw0rp@gmail.com> | 2018-08-02 23:44:12 +0100 |
---|---|---|
committer | w0rp <devw0rp@gmail.com> | 2018-08-02 23:44:12 +0100 |
commit | 217284360d35711b751859ed27a7a3c3da300e85 (patch) | |
tree | 4b26a84b397e3ac15a8b13a572b1f9a50312dbab /ale_linters/awk | |
parent | 9ef266d050d698c3ed3be3456ce6a5da5755d5ef (diff) | |
download | ale-217284360d35711b751859ed27a7a3c3da300e85.zip |
Simplify the code for most linters and tests with closures
Diffstat (limited to 'ale_linters/awk')
-rw-r--r-- | ale_linters/awk/gawk.vim | 18 |
1 files changed, 5 insertions, 13 deletions
diff --git a/ale_linters/awk/gawk.vim b/ale_linters/awk/gawk.vim index 8b60815f..eb92e45e 100644 --- a/ale_linters/awk/gawk.vim +++ b/ale_linters/awk/gawk.vim @@ -1,29 +1,21 @@ " 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 +call ale#Set('awk_gawk_executable', 'gawk') +call ale#Set('awk_gawk_options', '') 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. - return ale#Escape(ale_linters#awk#gawk#GetExecutable(a:buffer)) - \ . " --source 'BEGIN { exit } END { exit 1 }'" + return '%e --source ' . ale#Escape('BEGIN { exit } END { exit 1 }') \ . ale#Pad(ale#Var(a:buffer, 'awk_gawk_options')) - \ . ' ' . '-f %t --lint /dev/null' + \ . ' -f %t --lint /dev/null' endfunction call ale#linter#Define('awk', { \ 'name': 'gawk', -\ 'executable_callback': 'ale_linters#awk#gawk#GetExecutable', +\ 'executable_callback': ale#VarFunc('awk_gawk_executable'), \ 'command_callback': 'ale_linters#awk#gawk#GetCommand', \ 'callback': 'ale#handlers#gawk#HandleGawkFormat', \ 'output_stream': 'both' |