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

Commit

Permalink
fix(builtins): golangci_lint now runs in monorepos
Browse files Browse the repository at this point in the history
  • Loading branch information
Arne Van Maele committed May 12, 2023
1 parent 08bb00c commit fa7c270
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion doc/BUILTINS.md
Original file line number Diff line number Diff line change
Expand Up @@ -1073,7 +1073,7 @@ local sources = { null_ls.builtins.diagnostics.golangci_lint }
- Filetypes: `{ "go" }`
- Method: `diagnostics_on_save`
- Command: `golangci-lint`
- Args: `{ "run", "--fix=false", "--out-format=json", "--path-prefix", "$ROOT" }`
- Args: `{ "run", "--fix=false", "--out-format=json" }`

### [gospel](https://github.com/kortschak/gospel)

Expand Down
10 changes: 6 additions & 4 deletions lua/null-ls/builtins/diagnostics/golangci_lint.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
local h = require("null-ls.helpers")
local methods = require("null-ls.methods")
local log = require("null-ls.logger")
local u = require("null-ls.utils")

local DIAGNOSTICS_ON_SAVE = methods.internal.DIAGNOSTICS_ON_SAVE

Expand All @@ -18,12 +19,13 @@ return h.make_builtin({
from_stderr = false,
ignore_stderr = true,
multiple_files = true,
cwd = h.cache.by_bufnr(function(params)
return u.root_pattern("go.mod")(params.bufname)
end),
args = {
"run",
"--fix=false",
"--out-format=json",
"--path-prefix",
"$ROOT",
},
format = "json",
check_exit_code = function(code)
Expand All @@ -39,12 +41,12 @@ return h.make_builtin({
if type(issues) == "table" then
for _, d in ipairs(issues) do
table.insert(diags, {
source = string.format("golangci-lint:%s", d.FromLinter),
source = string.format("golangci-lint: %s", d.FromLinter),
row = d.Pos.Line,
col = d.Pos.Column,
message = d.Text,
severity = h.diagnostics.severities["warning"],
filename = d.Pos.Filename,
filename = u.path.join(params.cwd, d.Pos.Filename),
})
end
end
Expand Down

0 comments on commit fa7c270

Please sign in to comment.