local g={"\066\117\102\087\114\105\116\101\080\111\115\116","\066\117\102\082\101\097\100\080\111\115\116","\073\110\115\101\114\116\076\101\097\118\101"}return{"\109\102\117\115\115\101\110\101\103\103\101\114\047\110\118\105\109-\108\105\110\116";event=g;enabled=true;opts={events=g;linters_by_ft={c={"\099\112\112\099\104\101\099\107"},lua={"\115\101\108\101\110\101"},yaml={"\121\097\109\108\108\105\110\116"}}};config=function(g,z)local P=require("\108\105\110\116")P.linters_by_ft=z.linters_by_ft table.insert(P.linters.cppcheck.args,"--\115\117\112\112\114\101\115\115\061\109\105\115\115\105\110\103\073\110\099\108\117\100\101\083\121\115\116\101\109")local O=vim.api.nvim_create_augroup("\108\105\110\116\105\110\103",{clear=true})vim.api.nvim_create_autocmd(z.events,{group=O;callback=function()P.try_lint()end})vim.api.nvim_create_user_command("\068\105\115\097\098\108\101\076\105\110\116\105\110\103",function()local g=vim.filetype.match({buf=0});(require("\108\105\110\116")).linters_by_ft[g]={}vim.diagnostic.hide()end,{desc="\068\105\115\097\098\108\101 \108\105\110\116\105\110\103 \102\111\114 \099\117\114\114\101\110\116 \102\105\108\101\116\121\112\101"})vim.keymap.set("\110","\060\108\101\097\100\101\114\062\116\076","\060\099\109\100\062\068\105\115\097\098\108\101\076\105\110\116\105\110\103\060\099\114\062",{desc="\084\111\103\103\108\101 \076\105\110\116\105\110\103"})end}
-- local config = vim.g.config.plugins.nvim_lint

local events = { 'BufWritePost', 'BufReadPost', 'InsertLeave' }
-- Plugin to handle linting
return {
  'mfussenegger/nvim-lint',
  event = events,
  enabled = true,
  opts = {
    events = events,
    linters_by_ft = {
      c = { 'cppcheck' },
      -- dockerfile = { 'hadolint' },
      -- go = { 'golangcilint' },
      lua = { 'selene' },
      -- sh = { 'shellcheck' },
      yaml = { 'yamllint' },
    },
  },
  config = function(_, opts)
    local lint = require 'lint'
    lint.linters_by_ft = opts.linters_by_ft

    -- extend ccpcheck configuration to solve an issue about include checkings
    -- https://github.com/danmar/cppcheck/pull/3824
    table.insert(lint.linters.cppcheck.args, '--suppress=missingIncludeSystem')

    local lint_augroup = vim.api.nvim_create_augroup('linting', { clear = true })
    vim.api.nvim_create_autocmd(opts.events, {
      group = lint_augroup,
      callback = function()
        lint.try_lint()
      end,
    })
    vim.api.nvim_create_user_command('DisableLinting', function()
      -- utils.notify("Disable Linting", vim.log.levels.INFO, "nvim-lint")
      local ft = vim.filetype.match { buf = 0 }
      require('lint').linters_by_ft[ft] = {}
      vim.diagnostic.hide()
    end, { desc = 'Disable linting for current filetype' })
    vim.keymap.set('n', '<leader>tL', '<cmd>DisableLinting<cr>', { desc = 'Toggle Linting' })
  end,
}
