Closed fredrikaverpil closed 7 months ago
I'm closing this as it does seem like the config file is ready properly - and this fieldalignment warning comes from something else entirely.
EDIT: looks like it's gopls which enables fieldalignment
:
{
"neovim/nvim-lspconfig",
opts = {
servers = {
gopls = {
keys = {
-- Workaround for the lack of a DAP strategy in neotest-go: https://github.com/nvim-neotest/neotest-go/issues/12
{ "<leader>td", "<cmd>lua require('dap-go').debug_test()<CR>", desc = "Debug Nearest (Go)" },
},
settings = {
gopls = {
gofumpt = true,
codelenses = {
gc_details = false,
generate = true,
regenerate_cgo = true,
run_govulncheck = true,
test = true,
tidy = true,
upgrade_dependency = true,
vendor = true,
},
hints = {
assignVariableTypes = true,
compositeLiteralFields = true,
compositeLiteralTypes = true,
constantValues = true,
functionTypeParameters = true,
parameterNames = true,
rangeVariableTypes = true,
},
analyses = {
fieldalignment = true,
nilness = true,
unusedparams = true,
unusedwrite = true,
useany = true,
},
usePlaceholders = true,
completeUnimported = true,
staticcheck = true,
directoryFilters = { "-.git", "-.vscode", "-.idea", "-.vscode-test", "-node_modules" },
semanticTokens = true,
},
},
},
},
setup = {
gopls = function(_, opts)
-- workaround for gopls not supporting semanticTokensProvider
-- https://github.com/golang/go/issues/54531#issuecomment-1464982242
require("lazyvim.util").lsp.on_attach(function(client, _)
if client.name == "gopls" then
if not client.server_capabilities.semanticTokensProvider then
local semantic = client.config.capabilities.textDocument.semanticTokens
client.server_capabilities.semanticTokensProvider = {
full = true,
legend = {
tokenTypes = semantic.tokenTypes,
tokenModifiers = semantic.tokenModifiers,
},
range = true,
}
end
end
end)
-- end workaround
end,
},
},
}
Hello π
What's the problem?
I'm overriding
require("lint").linters.golangcilint.args
so to read a.golangci.yml
config file which tells golangci-lint which linters to use. To be precise, I want to disable thefieldalignment (default)
warning. Whatever I do to my.golangci.yml
config, I keep seeing this kind of warning.What did I do?
I'm trying to override
require("lint").linters.golangcilint.args
, so to inject--config <path-to-config-file>
when a.golangci.yml
file exists somewhere in my project.If I disable all linters in the config file, I still see the default golangci-lint diagnostics in Neovim whereas I would've expected none to show:
If I instead run the
golangci-lint
command manually, I can clearly see that the config file has an effect on the linting output:What could be wrong? Can I not supply the arguments the way I do it, is something wrong in my lua code?
Here is the original, default, setup for golangcilint in this repo.
My setup
Here are the helper functions:
If I add in print statements, I can see how the
.golangci.yml
file is properly detected and I can see how the arguments are properly populated.