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",
|
"williamboman/mason-lspconfig.nvim",
|
||||||
cmd = { "LspInstall", "LspUninstall" },
|
cmd = { "LspInstall", "LspUninstall" },
|
||||||
},
|
},
|
||||||
{
|
{ "WhoIsSethDaniel/mason-tool-installer.nvim" },
|
||||||
"WhoIsSethDaniel/mason-tool-installer.nvim",
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
event = { "BufRead", "BufNewFile", "InsertEnter" },
|
event = { "BufRead", "BufNewFile", "InsertEnter" },
|
||||||
after = { "nvim-cmp" },
|
after = { "nvim-cmp" },
|
||||||
|
@ -80,36 +78,18 @@ return {
|
||||||
"mfussenegger/nvim-lint",
|
"mfussenegger/nvim-lint",
|
||||||
config = function()
|
config = function()
|
||||||
local linters = {
|
local linters = {
|
||||||
astro = {},
|
astro = { "eslint_d" },
|
||||||
bash = {},
|
bash = { "shellcheck" },
|
||||||
javascript = {},
|
javascript = { "eslint_d" },
|
||||||
javascriptreact = {},
|
javascriptreact = { "eslint_d" },
|
||||||
markdown = {},
|
markdown = { "markdownlint", "vale" },
|
||||||
quarto = {},
|
quarto = { "markdownlint", "vale" },
|
||||||
sh = {},
|
sh = { "shellcheck" },
|
||||||
svelte = {},
|
svelte = { "eslint_d" },
|
||||||
text = {},
|
text = { "vale" },
|
||||||
typescript = {},
|
typescript = { "eslint_d" },
|
||||||
typescriptreact = {},
|
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
|
require("lint").linters_by_ft = linters
|
||||||
vim.api.nvim_create_autocmd({ "BufWritePost", "InsertLeave" }, {
|
vim.api.nvim_create_autocmd({ "BufWritePost", "InsertLeave" }, {
|
||||||
callback = function()
|
callback = function()
|
||||||
|
|
Loading…
Reference in a new issue