This repository has been archived by the owner on Aug 12, 2023. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #339 from jose-elias-alvarez/on-save-handling
feat: migrate to diagnostic API and support linting on save (feat. golangci-lint)
- Loading branch information
Showing
17 changed files
with
518 additions
and
250 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
local h = require("null-ls.helpers") | ||
local methods = require("null-ls.methods") | ||
|
||
local DIAGNOSTICS_ON_SAVE = methods.internal.DIAGNOSTICS_ON_SAVE | ||
|
||
return h.make_builtin({ | ||
method = DIAGNOSTICS_ON_SAVE, | ||
filetypes = { "go" }, | ||
generator_opts = { | ||
command = "golangci-lint", | ||
to_stdin = true, | ||
from_stderr = false, | ||
args = { | ||
"run", | ||
"--fix=false", | ||
"--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 = {} | ||
local issues = params.output["Issues"] | ||
if type(issues) == "table" then | ||
for _, d in ipairs(issues) do | ||
if d.Pos.Filename == params.bufname then | ||
table.insert(diags, { | ||
row = d.Pos.Line, | ||
col = d.Pos.Column, | ||
message = d.Text, | ||
}) | ||
end | ||
end | ||
end | ||
return diags | ||
end, | ||
}, | ||
factory = h.generator_factory, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.