mirror of
https://github.com/dense-analysis/ale
synced 2024-12-17 20:05:31 +00:00
Add support for zeek (#3952)
This commit is contained in:
parent
da331acc9e
commit
92f08b5af2
22
ale_linters/zeek/zeek.vim
Normal file
22
ale_linters/zeek/zeek.vim
Normal file
@ -0,0 +1,22 @@
|
||||
" Author: Benjamin Bannier <bbannier@gmail.com>
|
||||
" Description: Support for checking Zeek files.
|
||||
"
|
||||
call ale#Set('zeek_zeek_executable', 'zeek')
|
||||
|
||||
function! ale_linters#zeek#zeek#HandleErrors(buffer, lines) abort
|
||||
let l:pattern = 'error in \v.*, line (\d+): (.*)$'
|
||||
|
||||
return map(ale#util#GetMatches(a:lines, l:pattern), "{
|
||||
\ 'lnum': str2nr(v:val[1]),
|
||||
\ 'text': v:val[2],
|
||||
\}")
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('zeek', {
|
||||
\ 'name': 'zeek',
|
||||
\ 'executable': {b -> ale#Var(b, 'zeek_zeek_executable')},
|
||||
\ 'output_stream': 'stderr',
|
||||
\ 'command': {-> '%e --parse-only %s'},
|
||||
\ 'callback': 'ale_linters#zeek#zeek#HandleErrors',
|
||||
\ 'lint_file': 1,
|
||||
\})
|
@ -601,6 +601,8 @@ Notes:
|
||||
* `yamllint`
|
||||
* YANG
|
||||
* `yang-lsp`
|
||||
* Zeek
|
||||
* `zeek`!!
|
||||
* Zig
|
||||
* `zls`
|
||||
|
||||
|
23
doc/ale-zeek.txt
Normal file
23
doc/ale-zeek.txt
Normal file
@ -0,0 +1,23 @@
|
||||
===============================================================================
|
||||
ALE Zeek Integration *ale-zeek-options*
|
||||
*ale-integration-zeek*
|
||||
|
||||
===============================================================================
|
||||
Integration Information
|
||||
|
||||
Currently, the only supported linter for Zeek is zeek.
|
||||
|
||||
===============================================================================
|
||||
zeek *ale-zeek-zeek*
|
||||
|
||||
g:ale_zeek_zeek_executable *g:ale_zeek_zeek_executable*
|
||||
*b:ale_zeek_zeek_executable*
|
||||
Type: |String|
|
||||
Default: `'zeek'`
|
||||
|
||||
This variable can be modified to change the executable path for `zeek`.
|
||||
|
||||
|
||||
===============================================================================
|
||||
vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:
|
||||
|
@ -3114,6 +3114,8 @@ documented in additional help files.
|
||||
yamllint..............................|ale-yaml-yamllint|
|
||||
yang....................................|ale-yang-options|
|
||||
yang-lsp..............................|ale-yang-lsp|
|
||||
zeek....................................|ale-zeek-options|
|
||||
zeek..................................|ale-zeek-zeek|
|
||||
zig.....................................|ale-zig-options|
|
||||
zls...................................|ale-zig-zls|
|
||||
|
||||
|
@ -610,5 +610,7 @@ formatting.
|
||||
* [yamllint](https://yamllint.readthedocs.io/)
|
||||
* YANG
|
||||
* [yang-lsp](https://github.com/theia-ide/yang-lsp)
|
||||
* Zeek
|
||||
* [zeek](http://zeek.org) :floppy_disk:
|
||||
* Zig
|
||||
* [zls](https://github.com/zigtools/zls)
|
||||
|
17
test/handler/test_zeek_handler.vader
Normal file
17
test/handler/test_zeek_handler.vader
Normal file
@ -0,0 +1,17 @@
|
||||
Before:
|
||||
runtime ale_linters/zeek/zeek.vim
|
||||
|
||||
After:
|
||||
call ale#linter#Reset()
|
||||
|
||||
Execute(The zeek handler should parse input correctly):
|
||||
AssertEqual
|
||||
\ [
|
||||
\ {
|
||||
\ 'lnum': 2,
|
||||
\ 'text': 'unknown identifier bar, at or near "bar"'
|
||||
\ },
|
||||
\ ],
|
||||
\ ale_linters#zeek#zeek#HandleErrors(bufnr(''), [
|
||||
\ 'error in /tmp/foo.zeek, line 2: unknown identifier bar, at or near "bar"'
|
||||
\ ])
|
17
test/linter/test_zeek.vader
Normal file
17
test/linter/test_zeek.vader
Normal file
@ -0,0 +1,17 @@
|
||||
Before:
|
||||
call ale#assert#SetUpLinterTest('zeek', 'zeek')
|
||||
|
||||
let b:command_tail = ' --parse-only %s'
|
||||
|
||||
After:
|
||||
call ale#assert#TearDownLinterTest()
|
||||
|
||||
unlet! b:command_tail
|
||||
|
||||
Execute(The default command should be correct):
|
||||
AssertLinter 'zeek', ale#Escape('zeek') . b:command_tail
|
||||
|
||||
Execute(The zeek executable should be configurable, and escaped properly):
|
||||
let g:ale_zeek_zeek_executable = 'executable with spaces'
|
||||
|
||||
AssertLinter 'executable with spaces', ale#Escape('executable with spaces') . b:command_tail
|
Loading…
Reference in New Issue
Block a user