feat: nvim new configs

This commit is contained in:
Rasyidan Akbar F. 2025-10-28 20:32:32 +07:00
commit 553ef00fa9
17 changed files with 447 additions and 96 deletions

View file

@ -5,10 +5,13 @@ return {
opts = {
events = { "BufWritePost", "BufReadPost", "InsertLeave" },
linters_by_ft = {
-- Add linters per filetype here
-- fish = { "fish" },
-- javascript = { "eslint_d" },
-- python = { "ruff" },
javascript = { "eslint" },
typescript = { "eslint" },
javascriptreact = { "eslint" },
typescriptreact = { "eslint" },
python = { "ruff" },
sh = { "shellcheck" },
bash = { "shellcheck" },
},
linters = {},
},
@ -26,21 +29,28 @@ return {
lint.linters_by_ft = opts.linters_by_ft
-- Debounced lint function
-- Debounced lint function with proper timer management
local timer = vim.uv.new_timer()
local function debounce_lint()
local timer = vim.uv.new_timer()
return function()
timer:start(100, 0, vim.schedule_wrap(lint.try_lint))
end
-- Stop existing timer before starting new one to prevent EALREADY error
timer:stop()
timer:start(100, 0, vim.schedule_wrap(lint.try_lint))
end
local lint_fn = debounce_lint()
-- Create autocommand for linting
vim.api.nvim_create_autocmd(opts.events, {
group = vim.api.nvim_create_augroup("nvim-lint", { clear = true }),
callback = debounce_lint,
})
-- Clean up timer on exit
vim.api.nvim_create_autocmd("VimLeavePre", {
group = vim.api.nvim_create_augroup("nvim-lint-cleanup", { clear = true }),
callback = function()
lint_fn()
if timer and not timer:is_closing() then
timer:stop()
timer:close()
end
end,
})
end,