summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ale_linters/zeek/zeek.vim22
-rw-r--r--doc/ale-supported-languages-and-tools.txt2
-rw-r--r--doc/ale-zeek.txt23
-rw-r--r--doc/ale.txt2
-rw-r--r--supported-tools.md2
-rw-r--r--test/handler/test_zeek_handler.vader17
-rw-r--r--test/linter/test_zeek.vader17
7 files changed, 85 insertions, 0 deletions
diff --git a/ale_linters/zeek/zeek.vim b/ale_linters/zeek/zeek.vim
new file mode 100644
index 00000000..e976d75c
--- /dev/null
+++ b/ale_linters/zeek/zeek.vim
@@ -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,
+\})
diff --git a/doc/ale-supported-languages-and-tools.txt b/doc/ale-supported-languages-and-tools.txt
index f98f9101..36ef83ea 100644
--- a/doc/ale-supported-languages-and-tools.txt
+++ b/doc/ale-supported-languages-and-tools.txt
@@ -601,6 +601,8 @@ Notes:
* `yamllint`
* YANG
* `yang-lsp`
+* Zeek
+ * `zeek`!!
* Zig
* `zls`
diff --git a/doc/ale-zeek.txt b/doc/ale-zeek.txt
new file mode 100644
index 00000000..910bc060
--- /dev/null
+++ b/doc/ale-zeek.txt
@@ -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:
+
diff --git a/doc/ale.txt b/doc/ale.txt
index 97242748..6cc81784 100644
--- a/doc/ale.txt
+++ b/doc/ale.txt
@@ -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|
diff --git a/supported-tools.md b/supported-tools.md
index f643be5f..b2c0ec48 100644
--- a/supported-tools.md
+++ b/supported-tools.md
@@ -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)
diff --git a/test/handler/test_zeek_handler.vader b/test/handler/test_zeek_handler.vader
new file mode 100644
index 00000000..07a80d86
--- /dev/null
+++ b/test/handler/test_zeek_handler.vader
@@ -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"'
+ \ ])
diff --git a/test/linter/test_zeek.vader b/test/linter/test_zeek.vader
new file mode 100644
index 00000000..af58a414
--- /dev/null
+++ b/test/linter/test_zeek.vader
@@ -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