From 8d0ca8f71ed0c30aa357f151b7d52ae4fccfdb23 Mon Sep 17 00:00:00 2001 From: Oliver Ladner Date: Wed, 4 Sep 2024 15:04:16 +0200 Subject: [PATCH] feat: add nvim-lint --- lua/weeheavy/plugins/lsp/nvim-lint.lua | 32 ++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 lua/weeheavy/plugins/lsp/nvim-lint.lua diff --git a/lua/weeheavy/plugins/lsp/nvim-lint.lua b/lua/weeheavy/plugins/lsp/nvim-lint.lua new file mode 100644 index 0000000..33524f2 --- /dev/null +++ b/lua/weeheavy/plugins/lsp/nvim-lint.lua @@ -0,0 +1,32 @@ +return { + "mfussenegger/nvim-lint", + event = { "BufReadPre", "BufNewFile" }, + config = function() + local lint = require("lint") + + lint.linters_by_ft = { + javascript = { "eslint_d" }, + typescript = { "eslint_d" }, + javascriptreact = { "eslint_d" }, + typescriptreact = { "eslint_d" }, + svelte = { "eslint_d" }, + python = { "pylint" }, + ansible = { "woke" }, + markdown = { "woke" }, + sh = { "woke" }, + } + + local lint_augroup = vim.api.nvim_create_augroup("lint", { clear = true }) + + vim.api.nvim_create_autocmd({ "BufEnter", "BufWritePost", "InsertLeave" }, { + group = lint_augroup, + callback = function() + lint.try_lint() + end, + }) + + vim.keymap.set("n", "l", function() + lint.try_lint() + end, { desc = "Trigger linting for current file" }) + end, +}