add: eslint_d for jsx and tsx

This commit is contained in:
asep.komarudin 2024-06-29 12:10:29 +07:00
parent 2f2909cfe4
commit d9702eb157
2 changed files with 24 additions and 2 deletions

View file

@ -13,7 +13,7 @@ if pcode.active_javascript_config.active then
"williamboman/mason-lspconfig.nvim",
opts = function(_, opts)
opts.ensure_installed = opts.ensure_installed or {}
vim.list_extend(opts.ensure_installed, { "html", "cssls", "emmet_ls", "jsonls", "tsserver" })
vim.list_extend(opts.ensure_installed, { "html", "eslint", "cssls", "emmet_ls", "jsonls", "tsserver" })
end,
},
{
@ -30,7 +30,7 @@ if pcode.active_javascript_config.active then
opts = function(_, opts)
opts.linters_by_ft = opts.linters_by_ft or {}
require("user.utils.masoncfg").try_install("eslint_d")
opts.linters_by_ft.javascript = { "eslint" }
opts.linters_by_ft.javascript = { "eslint_d" }
end,
},
{

View file

@ -64,10 +64,17 @@ return {
["yamllint"] = "yamllint",
}
-- add new mapping filetype
local addnew = {
["typescriptreact"] = "eslint_d",
["javascriptreact"] = "eslint_d",
}
local ignore = {
["php"] = "tlint",
}
-- local listtest = {}
for _, pkg in pairs(mason_reg.get_installed_packages()) do
for _, type in pairs(pkg.spec.categories) do
-- only act upon a Linter
@ -80,9 +87,23 @@ return {
if keymap[ftl] ~= nil then
ftl = keymap[ftl]
end
-- if substring(pkg.spec.name, "eslint") then
-- table.insert(listtest, ftl)
-- end
if name_map[pkg.spec.name] ~= nil then
pkg.spec.name = name_map[pkg.spec.name]
end
-- add new mapping language
for key, value in pairs(addnew) do
if value == pkg.spec.name then
opts.linters_by_ft[key] = opts.linters_by_ft[key] or {}
table.insert(opts.linters_by_ft[key], pkg.spec.name)
end
end
if ignore[ftl] ~= pkg.spec.name then
opts.linters_by_ft[ftl] = opts.linters_by_ft[ftl] or {}
table.insert(opts.linters_by_ft[ftl], pkg.spec.name)
@ -92,6 +113,7 @@ return {
end
end
end
-- print(table.concat(listtest, ","))
end,
config = function(_, opts)
require("lint").linters_by_ft = opts.linters_by_ft