From 64ad51048d8f490b57ca6e74864f4de3777ec2a7 Mon Sep 17 00:00:00 2001 From: Mark Korondi Date: Thu, 8 Jun 2017 19:26:21 +0200 Subject: [PATCH] Support for GNU Awk linting (#638) * GNU Awk linter support * Documentation for awk linter --- README.md | 1 + ale_linters/awk/gawk.vim | 26 ++++++++++++++++++++++++++ doc/ale-awk.txt | 25 +++++++++++++++++++++++++ 3 files changed, 52 insertions(+) create mode 100644 ale_linters/awk/gawk.vim create mode 100644 doc/ale-awk.txt diff --git a/README.md b/README.md index 01998c50..5aa4ff87 100644 --- a/README.md +++ b/README.md @@ -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/)| diff --git a/ale_linters/awk/gawk.vim b/ale_linters/awk/gawk.vim new file mode 100644 index 00000000..ac6e9154 --- /dev/null +++ b/ale_linters/awk/gawk.vim @@ -0,0 +1,26 @@ +" Author: kmarc +" 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' +\}) diff --git a/doc/ale-awk.txt b/doc/ale-awk.txt new file mode 100644 index 00000000..221bf8de --- /dev/null +++ b/doc/ale-awk.txt @@ -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: