Skip to content
This repository has been archived by the owner on Aug 12, 2023. It is now read-only.

Commit

Permalink
Add golangci-lint for golang linting
Browse files Browse the repository at this point in the history
  • Loading branch information
zalegrala committed Nov 9, 2021
1 parent 64b269b commit f38fa0e
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions lua/null-ls/builtins/diagnostics.lua
Original file line number Diff line number Diff line change
Expand Up @@ -841,4 +841,42 @@ M.qmllint = h.make_builtin({
factory = h.generator_factory,
})

M.golangci_lint = h.make_builtin({
method = DIAGNOSTICS,
filetypes = { "go" },
generator_opts = {
command = "golangci-lint",
to_stdin = true,
from_stderr = false,
args = {
"run",
"--fast",
"--out-format",
"json",
"$DIRNAME",
"--path-prefix",
"$ROOT",
},
format = "json",
check_exit_code = function(code)
return code <= 2
end,
on_output = function(params)
local diags = {}
for _, d in ipairs(params.output.Issues) do
print(d.Pos.Filename)
if d.Pos.Filename == params.bufname then
table.insert(diags, {
row = d.Pos.Line,
col = d.Pos.Column,
message = d.Text,
})
end
end
return diags
end,
},
factory = h.generator_factory,
})

return M

0 comments on commit f38fa0e

Please sign in to comment.