Merge pull request #1603 from roastedcheese/fix/golangci-lint
Some checks are pending
Set up binary cache / cachix (default) (push) Waiting to run
Set up binary cache / cachix (maximal) (push) Waiting to run
Set up binary cache / cachix (nix) (push) Waiting to run
Treewide Checks / Validate flake (push) Waiting to run
Treewide Checks / Check formatting (push) Waiting to run
Treewide Checks / Check source tree for typos (push) Waiting to run
Treewide Checks / Validate documentation builds (push) Waiting to run
Treewide Checks / Validate documentation builds-1 (push) Waiting to run
Treewide Checks / Validate documentation builds-2 (push) Waiting to run
Treewide Checks / Validate documentation builds-3 (push) Waiting to run
Treewide Checks / Validate hyperlinks in documentation sources (push) Waiting to run
Treewide Checks / Validate Editorconfig conformance (push) Waiting to run
Build and deploy documentation / Check latest commit (push) Waiting to run
Build and deploy documentation / publish (push) Blocked by required conditions

languages/go: fix scope of golangci-lint
This commit is contained in:
Snoweuph 2026-05-19 22:49:51 +02:00 committed by GitHub
commit 7a6c114744
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 31 additions and 9 deletions

View file

@ -551,4 +551,8 @@ https://github.com/gorbit99/codewindow.nvim
- Allow `vim.treesitter.context.setupOpts.max_lines` to also be given as a
string in order to allow percentage values like `"20%"`
[RoastedCheese](https://github.com/roastedcheese):
- Fix `golangci-lint` to lint at the package level.
<!-- vim: set textwidth=80: -->

View file

@ -67,7 +67,21 @@
"--output.junit-xml.path="
"--output.teamcity.path="
"--output.sarif.path="
(mkLuaInline ''
-- Run on current file only if go.mod is missing
function()
local fnmod = ":p";
local cmd = {"${getExe pkgs.go}", "env", "GOMOD"};
local ok, gomod = pcall(vim.fn.system, cmd);
gomod = gomod:gsub("%s+", "")
if ok and gomod ~= "" and gomod ~= "/dev/null" then
fnmod = ":h";
end
return vim.fn.fnamemodify(vim.api.nvim_buf_get_name(0), fnmod)
end
'')
];
append_fname = false;
parser = mkLuaInline ''
function(output, bufnr)
local SOURCE = "golangci-lint";
@ -111,15 +125,19 @@
local normalized = issue.Severity:lower()
sev = severity_map[normalized] or vim.diagnostic.severity.ERROR
end
table.insert(diagnostics, {
bufnr = bufnr,
lnum = issue.Pos.Line - 1,
col = issue.Pos.Column - 1,
message = issue.Text,
code = issue.FromLinter,
severity = sev,
source = SOURCE,
})
local buffer = vim.fn.fnamemodify(vim.api.nvim_buf_get_name(bufnr), ":p")
if vim.fs.normalize(buffer) == vim.fs.normalize(issue.Pos.Filename) then
table.insert(diagnostics, {
bufnr = bufnr,
lnum = issue.Pos.Line - 1,
col = issue.Pos.Column - 1,
message = issue.Text,
code = issue.FromLinter,
severity = sev,
source = SOURCE,
})
end
end
return diagnostics
end