forked from drmargarido/linters
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlinter_gocompiler.lua
29 lines (26 loc) · 924 Bytes
/
linter_gocompiler.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
local linter = require "plugins.linter"
local PATHSEP = package.config:sub(1, 1)
local pattern = function(text, filename)
local line, col, warn, path, l, c, w
for line_text in text:gmatch("[^\n]+") do
path, l, c, w = line_text:match("([^:]+):(%d+):(%d+):[%s]?([^\n]+)")
local has_filename = path and filename:match(linter.escape_to_pattern(path))
if path then
if warn then -- End of the last warning
coroutine.yield(line, col, warn)
warn = nil
end
if has_filename then line, col, warn = l, c, w end
else
if warn then warn = warn.."\n"..line_text end
end
end
-- When we reach the end of the lines we didn't report the last warning
if warn then coroutine.yield(line, col, warn) end
end
linter.add_language {
file_patterns = {"%.go$"},
warning_pattern = pattern,
command = "go vet -source $FILENAME"..PATHSEP..".."..PATHSEP.." 2>&1",
args = {}
}