Support for GNU Awk linting (#638)

* GNU Awk linter support

* Documentation for awk linter
This commit is contained in:
Mark Korondi 2017-06-08 19:26:21 +02:00 committed by w0rp
parent 62862c3347
commit 64ad51048d
3 changed files with 52 additions and 0 deletions

View File

@ -58,6 +58,7 @@ name. That seems to be the fairest way to arrange this table.
| ASM | [gcc](https://gcc.gnu.org) |
| Ansible | [ansible-lint](https://github.com/willthames/ansible-lint) |
| AsciiDoc | [proselint](http://proselint.com/)|
| Awk | [gawk](https://www.gnu.org/software/gawk/)|
| Bash | [-n flag](https://www.gnu.org/software/bash/manual/bash.html#index-set), [shellcheck](https://www.shellcheck.net/) |
| Bourne Shell | [-n flag](http://linux.die.net/man/1/sh), [shellcheck](https://www.shellcheck.net/) |
| C | [cppcheck](http://cppcheck.sourceforge.net), [gcc](https://gcc.gnu.org/), [clang](http://clang.llvm.org/)|

26
ale_linters/awk/gawk.vim Normal file
View File

@ -0,0 +1,26 @@
" 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
return ale_linters#awk#gawk#GetExecutable(a:buffer)
\ . ' ' . 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',
\ 'callback': 'ale#handlers#cpplint#HandleCppLintFormat',
\ 'output_stream': 'both'
\})

25
doc/ale-awk.txt Normal file
View File

@ -0,0 +1,25 @@
===============================================================================
ALE Awk Integration *ale-awk-options*
-------------------------------------------------------------------------------
gawk *ale-awk-gawk*
g:ale_awk_gawk_executable *g:ale_awk_gawk_executable*
*b:ale_awk_gawk_executable*
Type: |String|
Default: `'gawk'`
This variable sets executable used for gawk.
g:ale_awk_gawk_options *g:ale_awk_gawk_options*
*b:ale_awk_gawk_options*
Type: |String|
Default: `''`
With this variable we are able to pass extra arguments for gawk
for invocation.
-------------------------------------------------------------------------------
vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: