neovim/lua/weeheavy/plugins/lsp/nvim-lint.lua

64 lines
2 KiB
Lua

-- You can see which linters are running with require("lint").get_running()
return {
"mfussenegger/nvim-lint",
event = "VeryLazy",
opts = {
-- other config
linters = {
eslint_d = {
args = {
"--no-warn-ignored", -- <-- this is the key argument
"--format",
"json",
"--stdin",
"--stdin-filename",
function()
return vim.api.nvim_buf_get_name(0)
end,
},
},
gitleaks = {
args = {
"--stdin",
function()
return vim.api.nvim_buf_get_name(0)
end,
},
},
},
},
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 = { "ruff" },
lua = { "woke" },
ansible = { "woke" },
markdown = { "woke", "proselint", "write_good" },
text = { "gitleaks", "proselint", "write_good" },
sh = { "gitleaks", "woke" },
bash = { "gitleaks" },
go = { "golangcilint" },
}
local lint_augroup = vim.api.nvim_create_augroup("lint", { clear = true })
vim.api.nvim_create_autocmd({ "BufEnter", "BufReadPost", "BufWritePost", "InsertLeave" }, {
group = lint_augroup,
callback = function()
lint.try_lint() -- linters_by_ft
-- lint.try_lint("gitleaks") -- on all ft
end,
})
vim.keymap.set("n", "<leader>l", function()
lint.try_lint() -- linters_by_ft
-- lint.try_lint("gitleaks") -- on all ft
end, { desc = "Lint current file" })
end,
}