Files
dotfiles/nvim/.config/nvim/lua/plugins/nvim-lint.lua
T
2025-12-20 17:43:24 +01:00

66 lines
1.7 KiB
Lua

return {
{
"mfussenegger/nvim-lint",
event = { "BufReadPre", "BufNewFile" },
config = function()
local lint = require("lint")
lint.linters_by_ft = {
-- Python
python = { "ruff" }, -- Fast! Replaces pylint, flake8, isort
-- Alternative: python = { "pylint" },
-- Or combine: python = { "ruff", "mypy" }, -- ruff + type checking
-- Bash/Shell
sh = { "shellcheck" },
bash = { "shellcheck" },
zsh = { "shellcheck" },
-- JSON
json = { "jsonlint" },
jsonc = { "jsonlint" },
-- CSS/SCSS
css = { "stylelint" },
scss = { "stylelint" },
sass = { "stylelint" },
less = { "stylelint" },
-- HTML
html = { "htmlhint" },
-- Alternative: html = { "tidy" },
-- Dockerfile (bonus)
dockerfile = { "hadolint" },
-- JavaScript/TypeScript (bonus)
javascript = { "eslint_d" },
typescript = { "eslint_d" },
javascriptreact = { "eslint_d" },
typescriptreact = { "eslint_d" },
-- Ruby (you already have this formatter)
ruby = { "rubocop" },
-- Markdown (bonus)
markdown = { "markdownlint" },
}
-- Auto-lint on save and when leaving insert mode
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,
})
-- Manual lint trigger
vim.keymap.set("n", "<leader>l", function()
lint.try_lint()
end, { desc = "Trigger linting" })
end,
},
}