nvim: Simplify linter loading function

This commit is contained in:
Marty Oehme 2023-12-26 10:08:51 +01:00
parent a5fee8959f
commit c977bfea06
Signed by: Marty
GPG key ID: EDBF2ED917B2EF6A

View file

@ -59,9 +59,7 @@ return {
"williamboman/mason-lspconfig.nvim",
cmd = { "LspInstall", "LspUninstall" },
},
{
"WhoIsSethDaniel/mason-tool-installer.nvim",
},
{ "WhoIsSethDaniel/mason-tool-installer.nvim" },
},
event = { "BufRead", "BufNewFile", "InsertEnter" },
after = { "nvim-cmp" },
@ -80,36 +78,18 @@ return {
"mfussenegger/nvim-lint",
config = function()
local linters = {
astro = {},
bash = {},
javascript = {},
javascriptreact = {},
markdown = {},
quarto = {},
sh = {},
svelte = {},
text = {},
typescript = {},
typescriptreact = {},
astro = { "eslint_d" },
bash = { "shellcheck" },
javascript = { "eslint_d" },
javascriptreact = { "eslint_d" },
markdown = { "markdownlint", "vale" },
quarto = { "markdownlint", "vale" },
sh = { "shellcheck" },
svelte = { "eslint_d" },
text = { "vale" },
typescript = { "eslint_d" },
typescriptreact = { "eslint_d" },
}
local per_cmd = function(cmd, ft_table)
if vim.fn.executable(cmd) == 1 then
for _, v in pairs(ft_table) do
table.insert(v, cmd)
end
end
end
per_cmd("markdownlint", { linters.markdown, linters.quarto })
per_cmd("vale", { linters.markdown, linters.text, linters.quarto })
per_cmd("shellcheck", { linters.sh, linters.bash })
per_cmd("eslint_d", {
linters.astro,
linters.javascript,
linters.javascriptreact,
linters.svelte,
linters.typescript,
linters.typescriptreact,
})
require("lint").linters_by_ft = linters
vim.api.nvim_create_autocmd({ "BufWritePost", "InsertLeave" }, {
callback = function()