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 Oct 23, 2022
1 parent bc1fc91 commit d34f699
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions lua/null-ls/builtins/diagnostics/golangci_lint.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,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",
"$DIRNAME",
"--path-prefix",
"$ROOT",
},
format = "json",
check_exit_code = function(code)
Expand All @@ -34,7 +36,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 d34f699

Please sign in to comment.