mirror of
https://github.com/pojokcodeid/nvim-lazy.git
synced 2025-06-21 16:39:04 +02:00
add: eslint_d for jsx and tsx
This commit is contained in:
parent
2f2909cfe4
commit
d9702eb157
2 changed files with 24 additions and 2 deletions
|
@ -13,7 +13,7 @@ if pcode.active_javascript_config.active then
|
||||||
"williamboman/mason-lspconfig.nvim",
|
"williamboman/mason-lspconfig.nvim",
|
||||||
opts = function(_, opts)
|
opts = function(_, opts)
|
||||||
opts.ensure_installed = opts.ensure_installed or {}
|
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,
|
end,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -30,7 +30,7 @@ if pcode.active_javascript_config.active then
|
||||||
opts = function(_, opts)
|
opts = function(_, opts)
|
||||||
opts.linters_by_ft = opts.linters_by_ft or {}
|
opts.linters_by_ft = opts.linters_by_ft or {}
|
||||||
require("user.utils.masoncfg").try_install("eslint_d")
|
require("user.utils.masoncfg").try_install("eslint_d")
|
||||||
opts.linters_by_ft.javascript = { "eslint" }
|
opts.linters_by_ft.javascript = { "eslint_d" }
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -64,10 +64,17 @@ return {
|
||||||
["yamllint"] = "yamllint",
|
["yamllint"] = "yamllint",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
-- add new mapping filetype
|
||||||
|
local addnew = {
|
||||||
|
["typescriptreact"] = "eslint_d",
|
||||||
|
["javascriptreact"] = "eslint_d",
|
||||||
|
}
|
||||||
|
|
||||||
local ignore = {
|
local ignore = {
|
||||||
["php"] = "tlint",
|
["php"] = "tlint",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
-- local listtest = {}
|
||||||
for _, pkg in pairs(mason_reg.get_installed_packages()) do
|
for _, pkg in pairs(mason_reg.get_installed_packages()) do
|
||||||
for _, type in pairs(pkg.spec.categories) do
|
for _, type in pairs(pkg.spec.categories) do
|
||||||
-- only act upon a Linter
|
-- only act upon a Linter
|
||||||
|
@ -80,9 +87,23 @@ return {
|
||||||
if keymap[ftl] ~= nil then
|
if keymap[ftl] ~= nil then
|
||||||
ftl = keymap[ftl]
|
ftl = keymap[ftl]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- if substring(pkg.spec.name, "eslint") then
|
||||||
|
-- table.insert(listtest, ftl)
|
||||||
|
-- end
|
||||||
|
|
||||||
if name_map[pkg.spec.name] ~= nil then
|
if name_map[pkg.spec.name] ~= nil then
|
||||||
pkg.spec.name = name_map[pkg.spec.name]
|
pkg.spec.name = name_map[pkg.spec.name]
|
||||||
end
|
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
|
if ignore[ftl] ~= pkg.spec.name then
|
||||||
opts.linters_by_ft[ftl] = opts.linters_by_ft[ftl] or {}
|
opts.linters_by_ft[ftl] = opts.linters_by_ft[ftl] or {}
|
||||||
table.insert(opts.linters_by_ft[ftl], pkg.spec.name)
|
table.insert(opts.linters_by_ft[ftl], pkg.spec.name)
|
||||||
|
@ -92,6 +113,7 @@ return {
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
-- print(table.concat(listtest, ","))
|
||||||
end,
|
end,
|
||||||
config = function(_, opts)
|
config = function(_, opts)
|
||||||
require("lint").linters_by_ft = opts.linters_by_ft
|
require("lint").linters_by_ft = opts.linters_by_ft
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue