feat: improve lint logic

This commit is contained in:
2025-10-26 05:49:02 +02:00
parent a4b5accc05
commit ae3d2d20ee
3 changed files with 26 additions and 13 deletions

View File

@@ -296,14 +296,28 @@ function M.lint.setup()
once = true,
callback = function()
local lint = require('lint')
lint.linters_by_ft = (M.general and M.general.linters_by_ft) or {}
vim.api.nvim_create_autocmd({ 'BufEnter', 'BufWritePost', 'InsertLeave' }, {
lint.linters_by_ft = M.general.linters_by_ft
function M.debounce(ms, fn)
local timer = vim.uv.new_timer()
return function(...)
local argv = { ... }
timer:start(ms, 0, function()
timer:stop()
vim.schedule_wrap(fn)(unpack(argv))
end)
end
end
function M.lint()
if vim.bo.modifiable then
lint.try_lint()
end
end
vim.api.nvim_create_autocmd({ 'BufReadPost', 'InsertLeave', 'TextChanged' }, {
group = vim.api.nvim_create_augroup('language-manager.lint', { clear = true }),
callback = function()
if vim.bo.modifiable then
lint.try_lint()
end
end,
callback = M.debounce(100, M.lint),
})
end,
})