-
Notifications
You must be signed in to change notification settings - Fork 69
/
lint.lua
36 lines (35 loc) · 1.19 KB
/
lint.lua
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
local utils = require("utils.functions")
return {
plugins = {
nvim_lint = {
enable = true,
config_function = function(opts)
local lint = require("lint")
lint.linters_by_ft = opts.linters_by_ft
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,
opts = {
events = { "BufWritePost", "BufReadPost", "InsertLeave" },
linters_by_ft = {
dockerfile = { "hadolint" },
go = { "golangcilint" },
lua = { "selene" },
yaml = { "yamllint" },
},
},
},
},
}