]> git.rmz.io Git - dotfiles.git/commitdiff
lazyvim: absorb linting plugins
authorSamir Benmendil <me@rmz.io>
Sun, 9 Feb 2025 23:05:25 +0000 (23:05 +0000)
committerSamir Benmendil <me@rmz.io>
Sun, 2 Mar 2025 15:44:14 +0000 (15:44 +0000)
nvim/lua/plugins/lint.lua [new file with mode: 0644]

diff --git a/nvim/lua/plugins/lint.lua b/nvim/lua/plugins/lint.lua
new file mode 100644 (file)
index 0000000..de4c4f2
--- /dev/null
@@ -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,
+  },
+}