aboutsummaryrefslogtreecommitdiff
path: root/nvim/lua/plugins/lint.lua
blob: 2bfcfc752ef5309412b5a39e4a0f9546fea33759 (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
30
31
-- Verfügbare Linter: https://github.com/mfussenegger/nvim-lint/tree/master/lua/lint/linters
--
-- Hier gehören nur Linter hinein, die kein Sprachserver ohnehin schon meldet:
-- shellcheck läuft in bashls, clang-tidy in clangd, ansible-lint in ansiblels.

local ruff = { "ruff" } -- bereits als Formatter installiert, siehe plugins/format.lua
local yamllint = { "yamllint" } -- brew install yamllint, pkg install devel/py-yamllint
local zsh = { "zsh" } -- kein zusätzliches Werkzeug: ruft `zsh --no-exec` auf

return {
  "mfussenegger/nvim-lint",
  event = { "BufReadPre", "BufNewFile" },
  config = function()
    local lint = require("lint")

    lint.linters_by_ft = {
      -- ergänzt die Typprüfung von basedpyright um die Lint-Regeln (F, E, UP, B ...)
      python = ruff,
      -- kein Sprachserver für YAML im Einsatz; Regeln kommen aus .yamllint des Projekts
      yaml = yamllint,
      -- Syntaxprüfung ohne Ausführung; bashls deckt nur sh und bash ab
      zsh = zsh,
    }

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