- Refactor dap.lua debugger configuration - Update neotest.lua test runner setup - Simplify linting.lua and formatting.lua configs - Restructure snippets.lua for better organization
45 lines
1.2 KiB
Lua
Executable file
45 lines
1.2 KiB
Lua
Executable file
return {
|
|
'mfussenegger/nvim-lint',
|
|
event = { 'BufReadPost', 'BufNewFile' },
|
|
opts = {
|
|
linters_by_ft = {
|
|
python = { 'ruff', 'mypy' },
|
|
go = { 'golangcilint' },
|
|
yaml = { 'yamllint' },
|
|
markdown = { 'markdownlint' },
|
|
sh = { 'shellcheck' },
|
|
lua = { 'luacheck' },
|
|
sql = { 'sqlfluff' },
|
|
},
|
|
},
|
|
config = function(_, opts)
|
|
local lint = require('lint')
|
|
lint.linters_by_ft = opts.linters_by_ft
|
|
|
|
local timer = vim.uv.new_timer()
|
|
local augroup = vim.api.nvim_create_augroup('LintAutogroup', { clear = true })
|
|
|
|
vim.api.nvim_create_autocmd({ 'BufEnter', 'BufWritePost', 'InsertLeave' }, {
|
|
group = augroup,
|
|
callback = function()
|
|
local ft = vim.bo.filetype
|
|
local available = lint.linters_by_ft[ft]
|
|
if not available or #available == 0 then
|
|
return
|
|
end
|
|
|
|
timer:stop()
|
|
timer:start(
|
|
250,
|
|
0,
|
|
vim.schedule_wrap(function()
|
|
local ok, err = pcall(lint.try_lint)
|
|
if not ok then
|
|
vim.notify('[nvim-lint] ' .. err, vim.log.levels.ERROR)
|
|
end
|
|
end)
|
|
)
|
|
end,
|
|
})
|
|
end,
|
|
}
|