summaryrefslogtreecommitdiff
path: root/lua/ben/plugins/linting.lua
blob: 3f28b537be4dc8616782063ad778d169fd3001d3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
return {
  "mfussenegger/nvim-lint",
  event = { "BufReadPre", "BufNewFile" },
  config = function()
    local lint = require("lint")
    lint.linters_by_ft = {
      css = { "stylelint" },
      markdown = { "markdownlint" },
      python = { "pylint" },
      -- go = { "golangci_lint" },
      sh = { "shellcheck" },
    }

    local lint_augroup = vim.api.nvim_create_augroup("link", { clear = true })

    vim.api.nvim_create_autocmd({ "BufEnter", "BufWritePost", "InsertLeave" }, {
      group = lint_augroup,
      callback = function()
        lint.try_lint()
      end,
    })
    vim.keymap.set("n", "<leader>l", function()
      lint.try_lint()
    end, {
      desc = "Trigger linting for current file",
      silent = true,
    })
  end,
}