nvim: Simplify linter loading function
This commit is contained in:
parent
a5fee8959f
commit
c977bfea06
1 changed files with 12 additions and 32 deletions
|
@ -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()
|
||||
|
|
Loading…
Reference in a new issue