]> git.rmz.io Git - dotfiles.git/blob - nvim/lua/plugins/lint.lua
de4c4f2b8cedbb51f070d2a0266cdbd242afd833
[dotfiles.git] / nvim / lua / plugins / lint.lua
1 local M = {}
2
3 return {
4 { "mfussenegger/nvim-lint",
5 event = "LazyFile",
6 opts = {
7 -- Event to trigger linters
8 events = { "BufWritePost", "BufReadPost", "InsertLeave" },
9 linters_by_ft = { },
10 -- NOTE: LazyVim had an extension to support global and fallback linters,
11 -- and conditionally enable a linter
12 },
13 config = function(_, opts)
14 function M.debounce(ms, fn)
15 local timer = vim.uv.new_timer()
16 return function(...)
17 local argv = { ... }
18 timer:start(ms, 0, function()
19 timer:stop()
20 vim.schedule_wrap(fn)(unpack(argv))
21 end)
22 end
23 end
24
25 local lint = require('lint')
26 function M.lint()
27 lint.try_lint()
28 end
29 vim.api.nvim_create_autocmd(opts.events, {
30 group = vim.api.nvim_create_augroup("nvim-lint", { clear = true }),
31 callback = M.debounce(100, M.lint),
32 })
33 end,
34 },
35 }