mirror of
https://github.com/pojokcodeid/nvim-lazy.git
synced 2025-06-21 08:35:48 +02:00
enc: add auto lint nvim-lint
This commit is contained in:
parent
19abed8ac0
commit
e7c7785cc5
3 changed files with 173 additions and 135 deletions
|
@ -2,7 +2,8 @@
|
||||||
"Comment.nvim": { "branch": "master", "commit": "e51f2b142d88bb666dcaa77d93a07f4b419aca70" },
|
"Comment.nvim": { "branch": "master", "commit": "e51f2b142d88bb666dcaa77d93a07f4b419aca70" },
|
||||||
"LuaSnip": { "branch": "master", "commit": "03c8e67eb7293c404845b3982db895d59c0d1538" },
|
"LuaSnip": { "branch": "master", "commit": "03c8e67eb7293c404845b3982db895d59c0d1538" },
|
||||||
"alpha-nvim": { "branch": "main", "commit": "41283fb402713fc8b327e60907f74e46166f4cfd" },
|
"alpha-nvim": { "branch": "main", "commit": "41283fb402713fc8b327e60907f74e46166f4cfd" },
|
||||||
"auto-conform.nvim": { "branch": "main", "commit": "08f9b7b43c847159413d64e5a793fe0b6ccb7d62" },
|
"auto-conform.nvim": { "branch": "main", "commit": "8d2fbcbd8b8dfd44e1bc2edffc3fe7372b5b520e" },
|
||||||
|
"auto-lint.nvim": { "branch": "main", "commit": "fa2c16211524e965242196e55b1f748d63332dcd" },
|
||||||
"bigfile.nvim": { "branch": "main", "commit": "33eb067e3d7029ac77e081cfe7c45361887a311a" },
|
"bigfile.nvim": { "branch": "main", "commit": "33eb067e3d7029ac77e081cfe7c45361887a311a" },
|
||||||
"bufferline.nvim": { "branch": "main", "commit": "81820cac7c85e51e4cf179f8a66d13dbf7b032d9" },
|
"bufferline.nvim": { "branch": "main", "commit": "81820cac7c85e51e4cf179f8a66d13dbf7b032d9" },
|
||||||
"cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" },
|
"cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" },
|
||||||
|
@ -21,7 +22,7 @@
|
||||||
"indent-blankline.nvim": { "branch": "master", "commit": "65e20ab94a26d0e14acac5049b8641336819dfc7" },
|
"indent-blankline.nvim": { "branch": "master", "commit": "65e20ab94a26d0e14acac5049b8641336819dfc7" },
|
||||||
"lazy.nvim": { "branch": "main", "commit": "cea5920abb202753004440f94ec39bcf2927e02e" },
|
"lazy.nvim": { "branch": "main", "commit": "cea5920abb202753004440f94ec39bcf2927e02e" },
|
||||||
"live-server.nvim": { "branch": "main", "commit": "f34ae262bf046981d9e5f7cd4f41a353a9647a22" },
|
"live-server.nvim": { "branch": "main", "commit": "f34ae262bf046981d9e5f7cd4f41a353a9647a22" },
|
||||||
"lsp-progress.nvim": { "branch": "main", "commit": "55a04895ea20c365b670051a3128265d43bdfa3d" },
|
"lsp-progress.nvim": { "branch": "main", "commit": "c5858bba2043cac5ad4113fe1263366125b1b314" },
|
||||||
"lualine.nvim": { "branch": "master", "commit": "0a5a66803c7407767b799067986b4dc3036e1983" },
|
"lualine.nvim": { "branch": "master", "commit": "0a5a66803c7407767b799067986b4dc3036e1983" },
|
||||||
"mason-lspconfig.nvim": { "branch": "main", "commit": "9ae570e206360e47d30b4c35a4550c165f4ea7b7" },
|
"mason-lspconfig.nvim": { "branch": "main", "commit": "9ae570e206360e47d30b4c35a4550c165f4ea7b7" },
|
||||||
"mason-nvim-dap.nvim": { "branch": "main", "commit": "4ba55f9755ebe8297d92c419b90a946123292ae6" },
|
"mason-nvim-dap.nvim": { "branch": "main", "commit": "4ba55f9755ebe8297d92c419b90a946123292ae6" },
|
||||||
|
@ -42,9 +43,9 @@
|
||||||
"nvim-navic": { "branch": "master", "commit": "8649f694d3e76ee10c19255dece6411c29206a54" },
|
"nvim-navic": { "branch": "master", "commit": "8649f694d3e76ee10c19255dece6411c29206a54" },
|
||||||
"nvim-nio": { "branch": "master", "commit": "7969e0a8ffabdf210edd7978ec954a47a737bbcc" },
|
"nvim-nio": { "branch": "master", "commit": "7969e0a8ffabdf210edd7978ec954a47a737bbcc" },
|
||||||
"nvim-notify": { "branch": "master", "commit": "d333b6f167900f6d9d42a59005d82919830626bf" },
|
"nvim-notify": { "branch": "master", "commit": "d333b6f167900f6d9d42a59005d82919830626bf" },
|
||||||
"nvim-scrollview": { "branch": "main", "commit": "06563ae0c9928a2df42aefe66f2aed2f2943e32e" },
|
"nvim-scrollview": { "branch": "main", "commit": "30ca6e18265928eb4ea7402346b4dfddbd8ce41e" },
|
||||||
"nvim-tree.lua": { "branch": "master", "commit": "2086e564c4d23fea714e8a6d63b881e551af2f41" },
|
"nvim-tree.lua": { "branch": "master", "commit": "2086e564c4d23fea714e8a6d63b881e551af2f41" },
|
||||||
"nvim-treesitter": { "branch": "master", "commit": "caf275382f91ec8a2498d455c4d7d3fd0265ebd3" },
|
"nvim-treesitter": { "branch": "master", "commit": "acc1708b962e12cc1d671cd530782727801804c3" },
|
||||||
"nvim-treesitter-textobjects": { "branch": "master", "commit": "34867c69838078df7d6919b130c0541c0b400c47" },
|
"nvim-treesitter-textobjects": { "branch": "master", "commit": "34867c69838078df7d6919b130c0541c0b400c47" },
|
||||||
"nvim-ts-autotag": { "branch": "main", "commit": "ddfccbf0df1b9349c2b9e9b17f4afa8f9b6c1ed1" },
|
"nvim-ts-autotag": { "branch": "main", "commit": "ddfccbf0df1b9349c2b9e9b17f4afa8f9b6c1ed1" },
|
||||||
"nvim-ts-context-commentstring": { "branch": "main", "commit": "2b7dcf6aab0947b9c4195f1d8aa592cdcd944ffe" },
|
"nvim-ts-context-commentstring": { "branch": "main", "commit": "2b7dcf6aab0947b9c4195f1d8aa592cdcd944ffe" },
|
||||||
|
|
37
lua/plugins/autolint.lua
Normal file
37
lua/plugins/autolint.lua
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
local M = {}
|
||||||
|
local disable = pcode.disable_null_ls or false
|
||||||
|
if require("user.utils.cfgstatus").cheack() then
|
||||||
|
disable = true
|
||||||
|
end
|
||||||
|
if disable then
|
||||||
|
M = {
|
||||||
|
"pojokcodeid/auto-lint.nvim",
|
||||||
|
dependencies = {
|
||||||
|
"mfussenegger/nvim-lint",
|
||||||
|
},
|
||||||
|
event = "VeryLazy",
|
||||||
|
config = function()
|
||||||
|
require("auto-lint").setup({
|
||||||
|
map_lang = {
|
||||||
|
-- ["c++"] = "cpp",
|
||||||
|
-- ["c#"] = "cs",
|
||||||
|
},
|
||||||
|
map_name = {
|
||||||
|
-- ["actionlint"] = "actionlint",
|
||||||
|
-- ["ansible_lint"] = "ansible_lint",
|
||||||
|
},
|
||||||
|
add_new = {
|
||||||
|
-- ["typescriptreact"] = { "eslint_d" },
|
||||||
|
-- ["javascriptreact"] = { "eslint_d" },
|
||||||
|
},
|
||||||
|
ignore = {
|
||||||
|
-- ["php"] = { "tlint" },
|
||||||
|
},
|
||||||
|
ensure_installed = {
|
||||||
|
-- "eslint_d",
|
||||||
|
},
|
||||||
|
})
|
||||||
|
end,
|
||||||
|
}
|
||||||
|
end
|
||||||
|
return M
|
|
@ -1,133 +1,133 @@
|
||||||
local M = {}
|
local M = {}
|
||||||
local disable = pcode.disable_null_ls or false
|
-- local disable = pcode.disable_null_ls or false
|
||||||
if require("user.utils.cfgstatus").cheack() then
|
-- if require("user.utils.cfgstatus").cheack() then
|
||||||
disable = true
|
-- disable = true
|
||||||
end
|
-- end
|
||||||
if disable then
|
-- if disable then
|
||||||
M = {
|
-- M = {
|
||||||
"mfussenegger/nvim-lint",
|
-- "mfussenegger/nvim-lint",
|
||||||
event = { "BufReadPre", "BufNewFile" },
|
-- event = { "BufReadPre", "BufNewFile" },
|
||||||
opts = function(_, opts)
|
-- opts = function(_, opts)
|
||||||
local mason_reg = require("mason-registry")
|
-- local mason_reg = require("mason-registry")
|
||||||
|
--
|
||||||
opts.linters_by_ft = opts.linters_by_ft or {}
|
-- opts.linters_by_ft = opts.linters_by_ft or {}
|
||||||
|
--
|
||||||
-- add diff langue vs filetype
|
-- -- add diff langue vs filetype
|
||||||
local keymap = {
|
-- local keymap = {
|
||||||
["c++"] = "cpp",
|
-- ["c++"] = "cpp",
|
||||||
["c#"] = "cs",
|
-- ["c#"] = "cs",
|
||||||
}
|
-- }
|
||||||
|
--
|
||||||
-- add dif nvim-lint vs mason
|
-- -- add dif nvim-lint vs mason
|
||||||
local name_map = {
|
-- local name_map = {
|
||||||
["actionlint"] = "actionlint",
|
-- ["actionlint"] = "actionlint",
|
||||||
["ansible_lint"] = "ansible_lint",
|
-- ["ansible_lint"] = "ansible_lint",
|
||||||
["buf"] = "buf_lint",
|
-- ["buf"] = "buf_lint",
|
||||||
["buildifier"] = "buildifier",
|
-- ["buildifier"] = "buildifier",
|
||||||
["cfn-lint"] = "cfn_lint",
|
-- ["cfn-lint"] = "cfn_lint",
|
||||||
["checkstyle"] = "checkstyle",
|
-- ["checkstyle"] = "checkstyle",
|
||||||
["clj-kondo"] = "clj_kondo",
|
-- ["clj-kondo"] = "clj_kondo",
|
||||||
["cmakelint"] = "cmakelint",
|
-- ["cmakelint"] = "cmakelint",
|
||||||
["codespell"] = "codespell",
|
-- ["codespell"] = "codespell",
|
||||||
["cpplint"] = "cpplint",
|
-- ["cpplint"] = "cpplint",
|
||||||
["cspell"] = "cspell",
|
-- ["cspell"] = "cspell",
|
||||||
["curlylint"] = "curlylint",
|
-- ["curlylint"] = "curlylint",
|
||||||
["djlint"] = "djlint",
|
-- ["djlint"] = "djlint",
|
||||||
["erb-lint"] = "erb_lint",
|
-- ["erb-lint"] = "erb_lint",
|
||||||
["eslint_d"] = "eslint_d",
|
-- ["eslint_d"] = "eslint_d",
|
||||||
["flake8"] = "flake8",
|
-- ["flake8"] = "flake8",
|
||||||
["gdtoolkit"] = "gdlint",
|
-- ["gdtoolkit"] = "gdlint",
|
||||||
["golangci-lint"] = "golangcilint",
|
-- ["golangci-lint"] = "golangcilint",
|
||||||
["hadolint"] = "hadolint",
|
-- ["hadolint"] = "hadolint",
|
||||||
["jsonlint"] = "jsonlint",
|
-- ["jsonlint"] = "jsonlint",
|
||||||
["ktlint"] = "ktlint",
|
-- ["ktlint"] = "ktlint",
|
||||||
["luacheck"] = "luacheck",
|
-- ["luacheck"] = "luacheck",
|
||||||
["markdownlint"] = "markdownlint",
|
-- ["markdownlint"] = "markdownlint",
|
||||||
["mypy"] = "mypy",
|
-- ["mypy"] = "mypy",
|
||||||
["phpcs"] = "phpcs",
|
-- ["phpcs"] = "phpcs",
|
||||||
["phpmd"] = "phpmd",
|
-- ["phpmd"] = "phpmd",
|
||||||
["phpstan"] = "phpstan",
|
-- ["phpstan"] = "phpstan",
|
||||||
["proselint"] = "proselint",
|
-- ["proselint"] = "proselint",
|
||||||
["pydocstyle"] = "pydocstyle",
|
-- ["pydocstyle"] = "pydocstyle",
|
||||||
["pylint"] = "pylint",
|
-- ["pylint"] = "pylint",
|
||||||
["revive"] = "revive",
|
-- ["revive"] = "revive",
|
||||||
["rstcheck"] = "rstcheck",
|
-- ["rstcheck"] = "rstcheck",
|
||||||
["rubocop"] = "rubocop",
|
-- ["rubocop"] = "rubocop",
|
||||||
["ruff"] = "ruff",
|
-- ["ruff"] = "ruff",
|
||||||
["selene"] = "selene",
|
-- ["selene"] = "selene",
|
||||||
["shellcheck"] = "shellcheck",
|
-- ["shellcheck"] = "shellcheck",
|
||||||
["sqlfluff"] = "sqlfluff",
|
-- ["sqlfluff"] = "sqlfluff",
|
||||||
["standardrb"] = "standardrb",
|
-- ["standardrb"] = "standardrb",
|
||||||
["stylelint"] = "stylelint",
|
-- ["stylelint"] = "stylelint",
|
||||||
["solhint"] = "solhint",
|
-- ["solhint"] = "solhint",
|
||||||
["tflint"] = "tflint",
|
-- ["tflint"] = "tflint",
|
||||||
["tfsec"] = "tfsec",
|
-- ["tfsec"] = "tfsec",
|
||||||
["trivy"] = "trivy",
|
-- ["trivy"] = "trivy",
|
||||||
["vale"] = "vale",
|
-- ["vale"] = "vale",
|
||||||
["vint"] = "vint",
|
-- ["vint"] = "vint",
|
||||||
["vulture"] = "vulture",
|
-- ["vulture"] = "vulture",
|
||||||
["yamllint"] = "yamllint",
|
-- ["yamllint"] = "yamllint",
|
||||||
}
|
-- }
|
||||||
|
--
|
||||||
-- add new mapping filetype
|
-- -- add new mapping filetype
|
||||||
local addnew = {
|
-- local addnew = {
|
||||||
["typescriptreact"] = "eslint_d",
|
-- ["typescriptreact"] = "eslint_d",
|
||||||
["javascriptreact"] = "eslint_d",
|
-- ["javascriptreact"] = "eslint_d",
|
||||||
["javascript.jsx"] = "eslint_d",
|
-- ["javascript.jsx"] = "eslint_d",
|
||||||
["typescript.tsx"] = "eslint_d",
|
-- ["typescript.tsx"] = "eslint_d",
|
||||||
["vue"] = "eslint_d",
|
-- ["vue"] = "eslint_d",
|
||||||
["sevelte"] = "eslint_d",
|
-- ["sevelte"] = "eslint_d",
|
||||||
["astro"] = "eslint_d",
|
-- ["astro"] = "eslint_d",
|
||||||
}
|
-- }
|
||||||
|
--
|
||||||
local ignore = {
|
-- local ignore = {
|
||||||
["php"] = "tlint",
|
-- ["php"] = "tlint",
|
||||||
}
|
-- }
|
||||||
|
--
|
||||||
-- local listtest = {}
|
-- -- 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
|
||||||
if type == "Linter" then
|
-- if type == "Linter" then
|
||||||
-- finally add the linter to it's compatible filetype(s)
|
-- -- finally add the linter to it's compatible filetype(s)
|
||||||
for _, ft in pairs(pkg.spec.languages) do
|
-- for _, ft in pairs(pkg.spec.languages) do
|
||||||
local ftl = string.lower(ft)
|
-- local ftl = string.lower(ft)
|
||||||
local ready = mason_reg.get_package(pkg.spec.name):is_installed()
|
-- local ready = mason_reg.get_package(pkg.spec.name):is_installed()
|
||||||
if ready then
|
-- if ready then
|
||||||
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
|
-- -- if substring(pkg.spec.name, "eslint") then
|
||||||
-- table.insert(listtest, ftl)
|
-- -- table.insert(listtest, ftl)
|
||||||
-- end
|
-- -- 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
|
-- -- add new mapping language
|
||||||
for key, value in pairs(addnew) do
|
-- for key, value in pairs(addnew) do
|
||||||
if value == pkg.spec.name then
|
-- if value == pkg.spec.name then
|
||||||
opts.linters_by_ft[key] = opts.linters_by_ft[key] or {}
|
-- opts.linters_by_ft[key] = opts.linters_by_ft[key] or {}
|
||||||
table.insert(opts.linters_by_ft[key], pkg.spec.name)
|
-- table.insert(opts.linters_by_ft[key], pkg.spec.name)
|
||||||
end
|
-- end
|
||||||
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)
|
||||||
end
|
-- end
|
||||||
end
|
-- end
|
||||||
end
|
-- end
|
||||||
end
|
-- end
|
||||||
end
|
-- end
|
||||||
end
|
-- end
|
||||||
-- print(table.concat(listtest, ","))
|
-- -- 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
|
||||||
end,
|
-- end,
|
||||||
}
|
-- }
|
||||||
end
|
-- end
|
||||||
return M
|
return M
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue