mirror of
https://github.com/dense-analysis/ale
synced 2024-12-30 18:12:08 +00:00
Add support for AVRA linting (#3950)
* Add support for AVRA linting * Add tests for AVRA linting and improve code * Fix test * Fix warning detection * Fix test * Fix test * Add AVRA as a supported language in docs
This commit is contained in:
parent
76c2293e68
commit
1e0e76bf96
36
ale_linters/avra/avra.vim
Normal file
36
ale_linters/avra/avra.vim
Normal file
@ -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',
|
||||
\})
|
26
doc/ale-avra.txt
Normal file
26
doc/ale-avra.txt
Normal file
@ -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:
|
@ -33,6 +33,8 @@ Notes:
|
||||
* `write-good`
|
||||
* ASM
|
||||
* `gcc`
|
||||
* AVRA
|
||||
* `avra`
|
||||
* Awk
|
||||
* `gawk`
|
||||
* Bash
|
||||
|
@ -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|
|
||||
|
@ -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
|
||||
|
24
test/handler/test_avra_handler.vader
Normal file
24
test/handler/test_avra_handler.vader
Normal file
@ -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"
|
||||
\ ])
|
29
test/linter/test_avra_avra.vader
Normal file
29
test/linter/test_avra_avra.vader
Normal file
@ -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
|
Loading…
Reference in New Issue
Block a user