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

Commit

Permalink
fix(builtins): set correct golangci_lint cwd
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelbeumer committed Dec 11, 2022
1 parent adaa799 commit f868cb5
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions lua/null-ls/builtins/diagnostics/golangci_lint.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,16 @@ return h.make_builtin({
to_stdin = true,
from_stderr = false,
ignore_stderr = true,
cwd = function(params)
local patterns = { "go.mod", "go.work", ".git" }
local opts = { upward = true, path = params.bufname }
local cwd = vim.fs.dirname(vim.fs.find(patterns, opts)[1]) or vim.fn.getcwd()
return vim.loop.fs_realpath(cwd)
end,
args = {
"run",
"--fix=false",
"--fast",
"--out-format=json",
"--path-prefix",
"$ROOT",
},
format = "json",
check_exit_code = function(code)
Expand All @@ -38,7 +41,8 @@ return h.make_builtin({
local issues = params.output["Issues"]
if type(issues) == "table" then
for _, d in ipairs(issues) do
if d.Pos.Filename == params.bufname then
local fname = params.cwd .. "/" .. d.Pos.Filename
if fname == params.bufname then
table.insert(diags, {
source = string.format("golangci-lint:%s", d.FromLinter),
row = d.Pos.Line,
Expand Down

0 comments on commit f868cb5

Please sign in to comment.