marleyvim/nvim/lua/plugins/linting/nvim-lint.lua

49 lines
1.2 KiB
Lua
Raw Normal View History

2024-12-15 12:57:27 -08:00
return {
'nvim-lint',
event = { 'BufReadPost', 'BufWritePost', 'BufNewFile' },
after = function()
local lint = require('lint')
lint.linters_by_ft = {
2025-01-05 11:25:37 -08:00
bash = { 'shellcheck' },
2024-12-15 12:57:27 -08:00
fish = { 'fish' },
2025-01-05 11:25:37 -08:00
nix = { 'statix' },
scss = { 'stylelint' },
sh = { 'shellcheck' },
yaml = { 'yamllint' },
2024-12-15 12:57:27 -08:00
}
2025-01-05 11:25:37 -08:00
local linters = {
shellcheck = {
args = {
'-x',
},
},
}
for name, linter in pairs(linters) do
if type(linter) == 'table' and type(lint.linters[name]) == 'table' then
lint.linters[name] =
vim.tbl_deep_extend('force', lint.linters[name], linter)
if type(linter.prepend_args) == 'table' then
lint.linters[name].args = lint.linters[name].args or {}
vim.list_extend(lint.linters[name].args, linter.prepend_args)
end
else
lint.linters[name] = linter
end
end
2024-12-15 12:57:27 -08:00
vim.api.nvim_create_autocmd(
{ 'BufWritePost', 'BufReadPost', 'InsertLeave' },
{
group = vim.api.nvim_create_augroup('nvim-lint', { clear = true }),
callback = function()
require('lint').try_lint()
end,
}
)
end,
}