summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ale_linters/avra/avra.vim36
-rw-r--r--doc/ale-avra.txt26
-rw-r--r--doc/ale-supported-languages-and-tools.txt2
-rw-r--r--doc/ale.txt2
-rw-r--r--supported-tools.md2
-rw-r--r--test/handler/test_avra_handler.vader24
-rw-r--r--test/linter/test_avra_avra.vader29
7 files changed, 121 insertions, 0 deletions
diff --git a/ale_linters/avra/avra.vim b/ale_linters/avra/avra.vim
new file mode 100644
index 00000000..edf15c09
--- /dev/null
+++ b/ale_linters/avra/avra.vim
@@ -0,0 +1,36 @@
+" Author: Utkarsh Verma <utkarshverma@protonmail.com>
+" Description: AVRA linter for avra syntax.
+
+call ale#Set('avra_avra_executable', 'avra')
+call ale#Set('avra_avra_options', '')
+
+function! ale_linters#avra#avra#GetCommand(buffer) abort
+ return '%e'
+ \ . ' %t'
+ \ . ale#Pad(ale#Var(a:buffer, 'avra_avra_options'))
+ \ . ' -o ' . g:ale#util#nul_file
+endfunction
+
+function! ale_linters#avra#avra#Handle(buffer, lines) abort
+ " Note that we treat 'fatal' as errors.
+ let l:pattern = '^\S\+(\(\d\+\))\s\+:\s\+\(\S\+\)\s\+:\s\+\(.\+\)$'
+ let l:output = []
+
+ for l:match in ale#util#GetMatches(a:lines, l:pattern)
+ call add(l:output, {
+ \ 'lnum': l:match[1] + 0,
+ \ 'type': l:match[2] =~? 'Error' ? 'E' : 'W',
+ \ 'text': l:match[3],
+ \})
+ endfor
+
+ return l:output
+endfunction
+
+call ale#linter#Define('avra', {
+\ 'name': 'avra',
+\ 'output_stream': 'stderr',
+\ 'executable': {b -> ale#Var(b, 'avra_avra_executable')},
+\ 'command': function('ale_linters#avra#avra#GetCommand'),
+\ 'callback': 'ale_linters#avra#avra#Handle',
+\})
diff --git a/doc/ale-avra.txt b/doc/ale-avra.txt
new file mode 100644
index 00000000..a61913ad
--- /dev/null
+++ b/doc/ale-avra.txt
@@ -0,0 +1,26 @@
+===============================================================================
+ALE AVRA Integration *ale-avra-options*
+
+
+===============================================================================
+avra *ale-avra-avra*
+
+g:ale_avra_avra_executable *g:ale_avra_avra_executable*
+ *b:ale_avra_avra_executable*
+
+ Type: |String|
+ Default `'avra'`
+
+ This variable can be changed to use different executable for AVRA.
+
+
+g:ale_avra_avra_options *g:ale_avra_avra_options*
+ *b:ale_avra_avra_options*
+ Type: |String|
+ Default: `''`
+
+ This variable can be set to pass additional options to AVRA.
+
+
+===============================================================================
+ vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:
diff --git a/doc/ale-supported-languages-and-tools.txt b/doc/ale-supported-languages-and-tools.txt
index bd23dade..5a780803 100644
--- a/doc/ale-supported-languages-and-tools.txt
+++ b/doc/ale-supported-languages-and-tools.txt
@@ -33,6 +33,8 @@ Notes:
* `write-good`
* ASM
* `gcc`
+* AVRA
+ * `avra`
* Awk
* `gawk`
* Bash
diff --git a/doc/ale.txt b/doc/ale.txt
index 752af42f..88835add 100644
--- a/doc/ale.txt
+++ b/doc/ale.txt
@@ -2633,6 +2633,8 @@ documented in additional help files.
textlint..............................|ale-asciidoc-textlint|
asm.....................................|ale-asm-options|
gcc...................................|ale-asm-gcc|
+ avra....................................|ale-avra-options|
+ avra..................................|ale-avra-avra|
awk.....................................|ale-awk-options|
gawk..................................|ale-awk-gawk|
bats....................................|ale-bats-options|
diff --git a/supported-tools.md b/supported-tools.md
index a0da372c..03d1ebb8 100644
--- a/supported-tools.md
+++ b/supported-tools.md
@@ -42,6 +42,8 @@ formatting.
* [write-good](https://github.com/btford/write-good)
* ASM
* [gcc](https://gcc.gnu.org)
+* AVRA
+ * [avra](https://github.com/Ro5bert/avra)
* Awk
* [gawk](https://www.gnu.org/software/gawk/)
* Bash
diff --git a/test/handler/test_avra_handler.vader b/test/handler/test_avra_handler.vader
new file mode 100644
index 00000000..0de83fb8
--- /dev/null
+++ b/test/handler/test_avra_handler.vader
@@ -0,0 +1,24 @@
+Before:
+ runtime ale_linters/avra/avra.vim
+
+After:
+ call ale#linter#Reset()
+
+Execute(The avra handler should parse errors correctly):
+ AssertEqual
+ \ [
+ \ {
+ \ 'lnum': 3,
+ \ 'text': "Unknown device: atmega3228p",
+ \ 'type': 'E'
+ \ },
+ \ {
+ \ 'lnum': 12,
+ \ 'text': "Unknown directive: .EQ",
+ \ 'type': 'E'
+ \ }
+ \ ],
+ \ ale_linters#avra#avra#Handle(bufnr(''), [
+ \ "main.asm(3) : Error : Unknown device: atmega3228p",
+ \ "main.asm(12) : Error : Unknown directive: .EQ"
+ \ ])
diff --git a/test/linter/test_avra_avra.vader b/test/linter/test_avra_avra.vader
new file mode 100644
index 00000000..04722d68
--- /dev/null
+++ b/test/linter/test_avra_avra.vader
@@ -0,0 +1,29 @@
+Before:
+ call ale#assert#SetUpLinterTest('avra', 'avra')
+
+ let b:command_tail = ' %t -o ' . g:ale#util#nul_file
+ let b:command_tail_opt = ' %t --max_errors 20 -o ' . g:ale#util#nul_file
+
+After:
+ unlet! b:command_tail
+ unlet! b:command_tail_opt
+
+ call ale#assert#TearDownLinterTest()
+
+Execute(The executable should be configurable):
+ AssertLinter 'avra', ale#Escape('avra') . b:command_tail,
+
+ let b:ale_avra_avra_executable = '~/avra'
+
+ AssertLinter '~/avra', ale#Escape('~/avra') . b:command_tail
+
+Execute(The options should be configurable):
+ let b:ale_avra_avra_options = '--max_errors 20'
+
+ AssertLinter 'avra', ale#Escape('avra')
+ \ . ' %t --max_errors 20 -o ' . g:ale#util#nul_file
+
+Execute(The options should be used in command):
+ let b:ale_avra_avra_options = '--max_errors 20'
+
+ AssertLinter 'avra', ale#Escape('avra') . b:command_tail_opt