aboutsummaryrefslogtreecommitdiffstats
path: root/.config/nvim/lua/eugenetriguba/plugins/nvim-lint.lua
blob: 10e88d6e36f5e3c35da440778fc294c065d33fd3 (plain) (blame)
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
vim.pack.add {
  {
    name = 'nvim-lint',
    src = 'https://github.com/mfussenegger/nvim-lint',
  },
}

-- Default linters, which will cause errors unless these tools are available:
-- {
--   clojure = { "clj-kondo" },
--   dockerfile = { "hadolint" },
--   inko = { "inko" },
--   janet = { "janet" },
--   json = { "jsonlint" },
--   markdown = { "vale" },
--   rst = { "vale" },
--   ruby = { "ruby" },
--   terraform = { "tflint" },
--   text = { "vale" }
-- }
--
-- Linters can be disabled by setting their filetypes to nil:
--    lint.linters_by_ft['clojure'] = nil
local lint = require 'lint'
lint.linters_by_ft = lint.linters_by_ft or {}
lint.linters_by_ft['cpp'] = { 'cppcheck' }
lint.linters_by_ft['dockerfile'] = { 'hadolint' }
lint.linters_by_ft['json'] = { 'jsonlint' }
lint.linters_by_ft['terraform'] = { 'tflint', 'terraform_validate' }
lint.linters_by_ft['python'] = { 'ruff' }
lint.linters_by_ft['markdown'] = { 'markdownlint', 'vale' }
lint.linters_by_ft['text'] = nil
lint.linters_by_ft['xml'] = { 'xmllint' }
lint.linters_by_ft['sh'] = { 'shellcheck' }
table.insert(lint.linters.shellcheck.args, '-x')

local lint_augroup = vim.api.nvim_create_augroup('lint', { clear = true })
vim.api.nvim_create_autocmd({ 'BufEnter', 'BufWritePost', 'InsertLeave' }, {
  group = lint_augroup,
  callback = function()
    -- Only run the linter in buffers that you can modify in order to
    -- avoid superfluous noise, notably within the handy LSP pop-ups that
    -- describe the hovered symbol using Markdown.
    if vim.opt_local.modifiable:get() then
      lint.try_lint()
    end
  end,
})