forked from liquidev/lintplus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzig.lua
54 lines (46 loc) · 1.29 KB
/
zig.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
-- Zig plugin for lint+
--- CONFIG ---
-- config.lint.zig_mode: "ast-check" | "build"
-- changes the linting mode. ast-check is a quick'n'dirty check (default),
-- build compiles the tests in a file (but does not run them).
-- config.lint.zig_args: table[string]
-- passes the given table of arguments to zig test. this does not have any
-- effect in "ast-check" mode.
--- IMPLEMENTATION ---
local core = require "core"
local lintplus = require "plugins.lintplus"
local mode = lintplus.config.zig_mode or "ast-check"
if mode ~= "ast-check" and mode ~= "build" then
core.error("lint+/zig: invalid zig_mode '%s'. "..
"available modes: 'ast-check', 'build'")
return
end
local command
if mode == "ast-check" then
command = lintplus.command {
"zig",
"ast-check",
"--color", "off",
lintplus.filename
}
elseif mode == "build" then
command = lintplus.args_command({
"zig",
"test",
"--color", "off",
"-fno-emit-bin",
lintplus.args,
lintplus.filename
}, "zig_args")
end
lintplus.add("zig") {
filename = "%.zig$",
procedure = {
command = command,
interpreter = lintplus.interpreter {
hint = "(.-):(%d+):(%d+): note: (.+)",
error = "(.-):(%d+):(%d+): error: (.+)",
warning = "(.-):(%d+):(%d+): warning: (.+)",
}
},
}