mfussenegger / nvim-lint

An asynchronous linter plugin for Neovim complementary to the built-in Language Server Protocol support.
GNU General Public License v3.0
2.03k stars 209 forks source link

[help] golangci-lint not showing any diagnostics #690

Open scottenock opened 4 weeks ago

scottenock commented 4 weeks ago

Hi there, I'm trying to configure golangci-lint but I can't for the life of me figure out what's wrong 🙈

plugins:

return {
  {
    "stevearc/conform.nvim",
    event = 'BufWritePre', -- uncomment for format on save
    opts = require "configs.conform",
  },

  -- These are some examples, uncomment them if you want to see them work!
  {
    "neovim/nvim-lspconfig",
    event = { "BufReadPre", "BufNewFile" },
    config = function()
      require("nvchad.configs.lspconfig").defaults()
      require "configs.lspconfig"
    end,
  },

  {
    "mfussenegger/nvim-lint",
    event = { "BufReadPre", "BufNewFile" },
    config = function()
      require "configs.lint"
    end,
  },
}

configs.lint.lua:

local lint = require("lint")

lint.linters_by_ft = {
  go = { "golangcilint" }
}

vim.api.nvim_create_autocmd({ "BufEnter", "BufWritePost", "InsertLeave" }, {
  callback = function()
    lint.try_lint()
  end,
})

vim.keymap.set("n", "<leader>li", function()
  lint.try_lint()
end, { desc = "Trigger linting for current file" })

vim.api.nvim_create_user_command("LintInfo", function()
  local filetype = vim.bo.filetype
  local linters = require("lint").linters_by_ft[filetype]

  if linters then
    print("Linters for " .. filetype .. ": " .. table.concat(linters, ", "))
  else
    print("No linters configured for filetype: " .. filetype)
  end
end, {})

I have verified that running golangci-lint from the command line I get a bunch of linting errors but inside nvim none of these appear 🤔

Appreciate any help regarding this 🙏

version installed: golangci-lint has version 1.61.0 built with go1.23.1 from a1d6c56 on 2024-09-09T14:33:19Z

dzolt-4chain commented 2 weeks ago

I've got the same problem. It shows diagnostic errors but inside error message and I cannot cycle through them

image
dzolt-4chain commented 2 weeks ago

I've managed to remove these errors by renaming my lint file from .golangci.yml to golangci-lint.yml. Please see @scottenock if thats your case