From: Samir Benmendil Date: Sun, 9 Feb 2025 23:05:25 +0000 (+0000) Subject: lazyvim: absorb linting plugins X-Git-Url: https://git.rmz.io/dotfiles.git/commitdiff_plain/c40b5f6397d7911ff823b94f6109518c939d2e41 lazyvim: absorb linting plugins --- diff --git a/nvim/lua/plugins/lint.lua b/nvim/lua/plugins/lint.lua new file mode 100644 index 0000000..de4c4f2 --- /dev/null +++ b/nvim/lua/plugins/lint.lua @@ -0,0 +1,35 @@ +local M = {} + +return { + { "mfussenegger/nvim-lint", + event = "LazyFile", + opts = { + -- Event to trigger linters + events = { "BufWritePost", "BufReadPost", "InsertLeave" }, + linters_by_ft = { }, + -- NOTE: LazyVim had an extension to support global and fallback linters, + -- and conditionally enable a linter + }, + config = function(_, opts) + 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 + + local lint = require('lint') + function M.lint() + lint.try_lint() + end + vim.api.nvim_create_autocmd(opts.events, { + group = vim.api.nvim_create_augroup("nvim-lint", { clear = true }), + callback = M.debounce(100, M.lint), + }) + end, + }, +}