mirror of
https://github.com/pojokcodeid/nvim-lazy.git
synced 2025-06-21 08:35:48 +02:00
add: auto switch to conform if use default config language
This commit is contained in:
parent
22202bc11b
commit
fbd69d94ec
7 changed files with 295 additions and 258 deletions
|
@ -1,6 +1,5 @@
|
||||||
{
|
{
|
||||||
"Comment.nvim": { "branch": "master", "commit": "e51f2b142d88bb666dcaa77d93a07f4b419aca70" },
|
"Comment.nvim": { "branch": "master", "commit": "e51f2b142d88bb666dcaa77d93a07f4b419aca70" },
|
||||||
"FixCursorHold.nvim": { "branch": "master", "commit": "1900f89dc17c603eec29960f57c00bd9ae696495" },
|
|
||||||
"LuaSnip": { "branch": "master", "commit": "03c8e67eb7293c404845b3982db895d59c0d1538" },
|
"LuaSnip": { "branch": "master", "commit": "03c8e67eb7293c404845b3982db895d59c0d1538" },
|
||||||
"alpha-nvim": { "branch": "main", "commit": "41283fb402713fc8b327e60907f74e46166f4cfd" },
|
"alpha-nvim": { "branch": "main", "commit": "41283fb402713fc8b327e60907f74e46166f4cfd" },
|
||||||
"bigfile.nvim": { "branch": "main", "commit": "33eb067e3d7029ac77e081cfe7c45361887a311a" },
|
"bigfile.nvim": { "branch": "main", "commit": "33eb067e3d7029ac77e081cfe7c45361887a311a" },
|
||||||
|
@ -13,8 +12,6 @@
|
||||||
"cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" },
|
"cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" },
|
||||||
"code_runner.nvim": { "branch": "main", "commit": "6c5bfe44a6c7523350cd706e6b3b8101166eed99" },
|
"code_runner.nvim": { "branch": "main", "commit": "6c5bfe44a6c7523350cd706e6b3b8101166eed99" },
|
||||||
"codeium.nvim": { "branch": "main", "commit": "d3b88eb3aa1de6da33d325c196b8a41da2bcc825" },
|
"codeium.nvim": { "branch": "main", "commit": "d3b88eb3aa1de6da33d325c196b8a41da2bcc825" },
|
||||||
"conform.nvim": { "branch": "master", "commit": "60e6fbddbdf37d7790de07dc7420beefaf650e5e" },
|
|
||||||
"crates.nvim": { "branch": "main", "commit": "8437522d12a8c523da2aee9db2979d070b2ecc33" },
|
|
||||||
"dracula.nvim": { "branch": "main", "commit": "8d8bddb8814c3e7e62d80dda65a9876f97eb699c" },
|
"dracula.nvim": { "branch": "main", "commit": "8d8bddb8814c3e7e62d80dda65a9876f97eb699c" },
|
||||||
"dressing.nvim": { "branch": "master", "commit": "71349f24c6e07b39f33600985843c289ca735308" },
|
"dressing.nvim": { "branch": "master", "commit": "71349f24c6e07b39f33600985843c289ca735308" },
|
||||||
"friendly-snippets": { "branch": "main", "commit": "682157939e57bd6a2c86277dfd4d6fbfce63dbac" },
|
"friendly-snippets": { "branch": "main", "commit": "682157939e57bd6a2c86277dfd4d6fbfce63dbac" },
|
||||||
|
@ -24,12 +21,14 @@
|
||||||
"lsp-progress.nvim": { "branch": "main", "commit": "55a04895ea20c365b670051a3128265d43bdfa3d" },
|
"lsp-progress.nvim": { "branch": "main", "commit": "55a04895ea20c365b670051a3128265d43bdfa3d" },
|
||||||
"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-null-ls.nvim": { "branch": "main", "commit": "2b8433f76598397fcc97318d410e0c4f7a4bea6a" },
|
||||||
"mason-nvim-dap.nvim": { "branch": "main", "commit": "f5425eb1d0d794f0305d5eeebddabb74614683ff" },
|
"mason-nvim-dap.nvim": { "branch": "main", "commit": "f5425eb1d0d794f0305d5eeebddabb74614683ff" },
|
||||||
"mason.nvim": { "branch": "main", "commit": "c43eeb5614a09dc17c03a7fb49de2e05de203924" },
|
"mason.nvim": { "branch": "main", "commit": "c43eeb5614a09dc17c03a7fb49de2e05de203924" },
|
||||||
"mini.indentscope": { "branch": "main", "commit": "56d42be090e8fcc68eda69cfe55af8c5e562300e" },
|
"mini.indentscope": { "branch": "main", "commit": "56d42be090e8fcc68eda69cfe55af8c5e562300e" },
|
||||||
"neoscroll.nvim": { "branch": "master", "commit": "a731f66f1d39ec6175fd201c5bf849e54abda99c" },
|
"neoscroll.nvim": { "branch": "master", "commit": "a731f66f1d39ec6175fd201c5bf849e54abda99c" },
|
||||||
"neotest": { "branch": "master", "commit": "f30bab1faef13d47f3905e065215c96a42d075ad" },
|
|
||||||
"noice.nvim": { "branch": "main", "commit": "03c6a75661e68012e30b0ed81f050358b1e2233c" },
|
"noice.nvim": { "branch": "main", "commit": "03c6a75661e68012e30b0ed81f050358b1e2233c" },
|
||||||
|
"none-ls-extras.nvim": { "branch": "main", "commit": "336e84b9e43c0effb735b08798ffac382920053b" },
|
||||||
|
"none-ls.nvim": { "branch": "main", "commit": "0d1b3fa2ad0b371b94cb4b9a27ba6e5a1a915c91" },
|
||||||
"nui.nvim": { "branch": "main", "commit": "a0fd35fcbb4cb479366f1dc5f20145fd718a3733" },
|
"nui.nvim": { "branch": "main", "commit": "a0fd35fcbb4cb479366f1dc5f20145fd718a3733" },
|
||||||
"nvim-autopairs": { "branch": "master", "commit": "c15de7e7981f1111642e7e53799e1211d4606cb9" },
|
"nvim-autopairs": { "branch": "master", "commit": "c15de7e7981f1111642e7e53799e1211d4606cb9" },
|
||||||
"nvim-cmp": { "branch": "main", "commit": "a110e12d0b58eefcf5b771f533fc2cf3050680ac" },
|
"nvim-cmp": { "branch": "main", "commit": "a110e12d0b58eefcf5b771f533fc2cf3050680ac" },
|
||||||
|
@ -37,7 +36,6 @@
|
||||||
"nvim-dap": { "branch": "master", "commit": "5ba8ceace596360321cf33fa4b56d9d46e057ce9" },
|
"nvim-dap": { "branch": "master", "commit": "5ba8ceace596360321cf33fa4b56d9d46e057ce9" },
|
||||||
"nvim-dap-ui": { "branch": "master", "commit": "f7d75cca202b52a60c520ec7b1ec3414d6e77b0f" },
|
"nvim-dap-ui": { "branch": "master", "commit": "f7d75cca202b52a60c520ec7b1ec3414d6e77b0f" },
|
||||||
"nvim-dap-virtual-text": { "branch": "master", "commit": "d7c695ea39542f6da94ee4d66176f5d660ab0a77" },
|
"nvim-dap-virtual-text": { "branch": "master", "commit": "d7c695ea39542f6da94ee4d66176f5d660ab0a77" },
|
||||||
"nvim-lint": { "branch": "master", "commit": "efc6fc83f0772283e064c53a8f9fb5645bde0bc0" },
|
|
||||||
"nvim-lspconfig": { "branch": "master", "commit": "0b8165cf95806bc4bb8f745bb0c92021b2ed4b98" },
|
"nvim-lspconfig": { "branch": "master", "commit": "0b8165cf95806bc4bb8f745bb0c92021b2ed4b98" },
|
||||||
"nvim-material-icon": { "branch": "main", "commit": "5ad42234d880659dfe9d4ff936c310cd6c5a1610" },
|
"nvim-material-icon": { "branch": "main", "commit": "5ad42234d880659dfe9d4ff936c310cd6c5a1610" },
|
||||||
"nvim-navic": { "branch": "master", "commit": "8649f694d3e76ee10c19255dece6411c29206a54" },
|
"nvim-navic": { "branch": "master", "commit": "8649f694d3e76ee10c19255dece6411c29206a54" },
|
||||||
|
@ -45,7 +43,7 @@
|
||||||
"nvim-notify": { "branch": "master", "commit": "d333b6f167900f6d9d42a59005d82919830626bf" },
|
"nvim-notify": { "branch": "master", "commit": "d333b6f167900f6d9d42a59005d82919830626bf" },
|
||||||
"nvim-scrollview": { "branch": "main", "commit": "06563ae0c9928a2df42aefe66f2aed2f2943e32e" },
|
"nvim-scrollview": { "branch": "main", "commit": "06563ae0c9928a2df42aefe66f2aed2f2943e32e" },
|
||||||
"nvim-tree.lua": { "branch": "master", "commit": "2086e564c4d23fea714e8a6d63b881e551af2f41" },
|
"nvim-tree.lua": { "branch": "master", "commit": "2086e564c4d23fea714e8a6d63b881e551af2f41" },
|
||||||
"nvim-treesitter": { "branch": "master", "commit": "3e535e826da265748b875b18dbfb361bd1a1701c" },
|
"nvim-treesitter": { "branch": "master", "commit": "fa19150d0057b22dde98746680162b9a7ab61d1e" },
|
||||||
"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": "cb064386e667def1d241317deed9fd1b38f0dc2e" },
|
"nvim-ts-context-commentstring": { "branch": "main", "commit": "cb064386e667def1d241317deed9fd1b38f0dc2e" },
|
||||||
|
@ -54,8 +52,6 @@
|
||||||
"plenary.nvim": { "branch": "master", "commit": "50012918b2fc8357b87cff2a7f7f0446e47da174" },
|
"plenary.nvim": { "branch": "master", "commit": "50012918b2fc8357b87cff2a7f7f0446e47da174" },
|
||||||
"rainbow-delimiters.nvim": { "branch": "master", "commit": "12b1a1e095d968887a17ef791c2edb78d7595d46" },
|
"rainbow-delimiters.nvim": { "branch": "master", "commit": "12b1a1e095d968887a17ef791c2edb78d7595d46" },
|
||||||
"rest.nvim": { "branch": "main", "commit": "91badd46c60df6bd9800c809056af2d80d33da4c" },
|
"rest.nvim": { "branch": "main", "commit": "91badd46c60df6bd9800c809056af2d80d33da4c" },
|
||||||
"rust.vim": { "branch": "master", "commit": "889b9a7515db477f4cb6808bef1769e53493c578" },
|
|
||||||
"rustaceanvim": { "branch": "master", "commit": "d6d7620b66d74b3b16defcf85cbef7b3582795b3" },
|
|
||||||
"smart-splits.nvim": { "branch": "master", "commit": "66fda3a601a5b4c679656f15eb6ddd613c8d3216" },
|
"smart-splits.nvim": { "branch": "master", "commit": "66fda3a601a5b4c679656f15eb6ddd613c8d3216" },
|
||||||
"telescope.nvim": { "branch": "master", "commit": "7bd2f9b72f8449780b79bcf351534e2cd36ec43a" },
|
"telescope.nvim": { "branch": "master", "commit": "7bd2f9b72f8449780b79bcf351534e2cd36ec43a" },
|
||||||
"tiny-devicons-auto-colors.nvim": { "branch": "main", "commit": "9be4af5b1bc1f26a11206ed7ce8bf44312e7941a" },
|
"tiny-devicons-auto-colors.nvim": { "branch": "main", "commit": "9be4af5b1bc1f26a11206ed7ce8bf44312e7941a" },
|
||||||
|
|
|
@ -45,7 +45,7 @@ pcode.format_timeout_ms = 5000
|
||||||
-- https://github.com/mfussenegger/nvim-lint
|
-- https://github.com/mfussenegger/nvim-lint
|
||||||
-- https://github.com/stevearc/conform.nvim
|
-- https://github.com/stevearc/conform.nvim
|
||||||
-- use conform and nvim-lint if set true
|
-- use conform and nvim-lint if set true
|
||||||
pcode.disable_null_ls = true
|
pcode.disable_null_ls = false
|
||||||
|
|
||||||
pcode.treesitter_ensure_installed = {}
|
pcode.treesitter_ensure_installed = {}
|
||||||
pcode.tscontext = false
|
pcode.tscontext = false
|
||||||
|
@ -161,7 +161,7 @@ pcode.rest_client = true
|
||||||
pcode.nvim_dap = true -- not support for windows os (auto config mason-nvim-dap)
|
pcode.nvim_dap = true -- not support for windows os (auto config mason-nvim-dap)
|
||||||
|
|
||||||
-- conefig special support test & dap
|
-- conefig special support test & dap
|
||||||
pcode.active_rust_config = true
|
pcode.active_rust_config = false
|
||||||
pcode.active_javascript_config = {
|
pcode.active_javascript_config = {
|
||||||
active = false,
|
active = false,
|
||||||
jest_command = "npm test -- ",
|
jest_command = "npm test -- ",
|
||||||
|
|
|
@ -1,132 +1,139 @@
|
||||||
return {
|
local M = {}
|
||||||
"stevearc/conform.nvim",
|
local disable = pcode.disable_null_ls or false
|
||||||
enabled = pcode.disable_null_ls or false,
|
if require("user.utils.cfgstatus").cheack() then
|
||||||
event = { "BufReadPre", "BufNewFile" },
|
disable = true
|
||||||
opts = function(_, opts)
|
end
|
||||||
local mason_reg = require("mason-registry")
|
if disable then
|
||||||
|
M = {
|
||||||
|
"stevearc/conform.nvim",
|
||||||
|
event = { "BufReadPre", "BufNewFile" },
|
||||||
|
opts = function(_, opts)
|
||||||
|
local mason_reg = require("mason-registry")
|
||||||
|
|
||||||
opts.formatters = opts.formatters or {}
|
opts.formatters = opts.formatters or {}
|
||||||
opts.formatters_by_ft = opts.formatters_by_ft or {}
|
opts.formatters_by_ft = opts.formatters_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",
|
||||||
["jsx"] = "javascriptreact",
|
["jsx"] = "javascriptreact",
|
||||||
}
|
}
|
||||||
|
|
||||||
-- add diff conform vs mason
|
-- add diff conform vs mason
|
||||||
local name_map = {
|
local name_map = {
|
||||||
["cmakelang"] = "cmake_format",
|
["cmakelang"] = "cmake_format",
|
||||||
["deno"] = "deno_fmt",
|
["deno"] = "deno_fmt",
|
||||||
["elm-format"] = "elm_format",
|
["elm-format"] = "elm_format",
|
||||||
["gdtoolkit"] = "gdformat",
|
["gdtoolkit"] = "gdformat",
|
||||||
["nixpkgs-fmt"] = "nixpkgs_fmt",
|
["nixpkgs-fmt"] = "nixpkgs_fmt",
|
||||||
["opa"] = "opa_fmt",
|
["opa"] = "opa_fmt",
|
||||||
["php-cs-fixer"] = "php_cs_fixer",
|
["php-cs-fixer"] = "php_cs_fixer",
|
||||||
["ruff"] = "ruff_format",
|
["ruff"] = "ruff_format",
|
||||||
["sql-formatter"] = "sql_formatter",
|
["sql-formatter"] = "sql_formatter",
|
||||||
["xmlformatter"] = "xmlformat",
|
["xmlformatter"] = "xmlformat",
|
||||||
}
|
}
|
||||||
|
|
||||||
-- add new mapping filetype
|
-- add new mapping filetype
|
||||||
local addnew = {
|
local addnew = {
|
||||||
["jsonc"] = "prettier",
|
["jsonc"] = "prettier",
|
||||||
["json"] = "prettier",
|
["json"] = "prettier",
|
||||||
["typescriptreact"] = "prettier",
|
["typescriptreact"] = "prettier",
|
||||||
}
|
}
|
||||||
|
|
||||||
-- add ignore filetype
|
-- add ignore filetype
|
||||||
local ignore = {
|
local ignore = {
|
||||||
["php"] = "tlint",
|
["php"] = "tlint",
|
||||||
}
|
}
|
||||||
|
|
||||||
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 formatter
|
-- only act upon a formatter
|
||||||
if type == "Formatter" then
|
if type == "Formatter" then
|
||||||
-- if formatter doesn't have a builtin config, create our own from a generic template
|
-- if formatter doesn't have a builtin config, create our own from a generic template
|
||||||
if not require("conform").get_formatter_config(pkg.spec.name) then
|
if not require("conform").get_formatter_config(pkg.spec.name) then
|
||||||
-- the key of the entry to this table
|
-- the key of the entry to this table
|
||||||
-- is the name of the bare executable
|
-- is the name of the bare executable
|
||||||
-- the actual value may not be the absolute path
|
-- the actual value may not be the absolute path
|
||||||
-- in some cases
|
-- in some cases
|
||||||
local bin = next(pkg.spec.bin)
|
local bin = next(pkg.spec.bin)
|
||||||
-- this should be replaced by a function
|
-- this should be replaced by a function
|
||||||
-- that quieries the configured mason install path
|
-- that quieries the configured mason install path
|
||||||
local prefix = vim.fn.stdpath("data") .. "/mason/bin/"
|
local prefix = vim.fn.stdpath("data") .. "/mason/bin/"
|
||||||
|
|
||||||
opts.formatters[pkg.spec.name] = {
|
opts.formatters[pkg.spec.name] = {
|
||||||
command = prefix .. bin,
|
command = prefix .. bin,
|
||||||
args = { "$FILENAME" },
|
args = { "$FILENAME" },
|
||||||
stdin = true,
|
stdin = true,
|
||||||
require_cwd = false,
|
require_cwd = false,
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
-- local listtest = {}
|
-- local listtest = {}
|
||||||
-- finally add the formatter to it's compatible filetype(s)
|
-- finally add the formatter 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)
|
||||||
-- register only ready installed package
|
-- register only ready installed package
|
||||||
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 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
|
||||||
|
|
||||||
-- if substring(pkg.spec.name, "prettier") then
|
-- if substring(pkg.spec.name, "prettier") then
|
||||||
-- table.insert(listtest, ftl)
|
-- table.insert(listtest, ftl)
|
||||||
-- 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.formatters_by_ft[key] = opts.formatters_by_ft[key] or {}
|
opts.formatters_by_ft[key] = opts.formatters_by_ft[key] or {}
|
||||||
table.insert(opts.formatters_by_ft[key], pkg.spec.name)
|
table.insert(opts.formatters_by_ft[key], pkg.spec.name)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if ignore[ftl] ~= pkg.spec.name then
|
||||||
|
opts.formatters_by_ft[ftl] = opts.formatters_by_ft[ftl] or {}
|
||||||
|
table.insert(opts.formatters_by_ft[ftl], pkg.spec.name)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if ignore[ftl] ~= pkg.spec.name then
|
|
||||||
opts.formatters_by_ft[ftl] = opts.formatters_by_ft[ftl] or {}
|
|
||||||
table.insert(opts.formatters_by_ft[ftl], pkg.spec.name)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
-- print(table.concat(listtest, ","))
|
||||||
end
|
end
|
||||||
-- print(table.concat(listtest, ","))
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
local onsave = pcode.format_on_save or false
|
local onsave = pcode.format_on_save or false
|
||||||
if onsave then
|
if onsave then
|
||||||
return {
|
return {
|
||||||
format_on_save = {
|
format_on_save = {
|
||||||
|
lsp_fallback = true,
|
||||||
|
timeout_ms = pcode.format_timeout_ms or 5000,
|
||||||
|
},
|
||||||
|
formatters = opts.formatters,
|
||||||
|
formatters_by_ft = opts.formatters_by_ft,
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return {
|
||||||
|
formatters = opts.formatters,
|
||||||
|
formatters_by_ft = opts.formatters_by_ft,
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
config = function(_, opts)
|
||||||
|
local conform = require("conform")
|
||||||
|
conform.setup(opts)
|
||||||
|
vim.keymap.set({ "n", "v" }, "<leader>lF", function()
|
||||||
|
conform.format({
|
||||||
lsp_fallback = true,
|
lsp_fallback = true,
|
||||||
|
async = false,
|
||||||
timeout_ms = pcode.format_timeout_ms or 5000,
|
timeout_ms = pcode.format_timeout_ms or 5000,
|
||||||
},
|
})
|
||||||
formatters = opts.formatters,
|
end, { desc = "Format file or range (in visual mode)" })
|
||||||
formatters_by_ft = opts.formatters_by_ft,
|
end,
|
||||||
}
|
}
|
||||||
else
|
end
|
||||||
return {
|
return M
|
||||||
formatters = opts.formatters,
|
|
||||||
formatters_by_ft = opts.formatters_by_ft,
|
|
||||||
}
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
config = function(_, opts)
|
|
||||||
local conform = require("conform")
|
|
||||||
conform.setup(opts)
|
|
||||||
vim.keymap.set({ "n", "v" }, "<leader>lF", function()
|
|
||||||
conform.format({
|
|
||||||
lsp_fallback = true,
|
|
||||||
async = false,
|
|
||||||
timeout_ms = pcode.format_timeout_ms or 5000,
|
|
||||||
})
|
|
||||||
end, { desc = "Format file or range (in visual mode)" })
|
|
||||||
end,
|
|
||||||
}
|
|
||||||
|
|
|
@ -20,6 +20,7 @@ if pcode.active_javascript_config.active then
|
||||||
"stevearc/conform.nvim",
|
"stevearc/conform.nvim",
|
||||||
event = "VeryLazy",
|
event = "VeryLazy",
|
||||||
opts = function(_, opts)
|
opts = function(_, opts)
|
||||||
|
opts.formatters_by_ft = opts.formatters_by_ft or {}
|
||||||
local package = "prettier"
|
local package = "prettier"
|
||||||
require("user.utils.masoncfg").try_install(package)
|
require("user.utils.masoncfg").try_install(package)
|
||||||
opts.formatters_by_ft.javascript = { package }
|
opts.formatters_by_ft.javascript = { package }
|
||||||
|
|
|
@ -1,25 +1,28 @@
|
||||||
return {
|
local M = {}
|
||||||
{
|
if not (pcode.disable_null_ls or false) then
|
||||||
"nvimtools/none-ls.nvim",
|
M = {
|
||||||
lazy = true,
|
{
|
||||||
enabled = not (pcode.disable_null_ls or false),
|
"nvimtools/none-ls.nvim",
|
||||||
dependencies = {
|
lazy = true,
|
||||||
{
|
dependencies = {
|
||||||
"jayp0521/mason-null-ls.nvim",
|
{
|
||||||
event = "VeryLazy",
|
"jayp0521/mason-null-ls.nvim",
|
||||||
opts = {
|
event = "VeryLazy",
|
||||||
ensure_installed = pcode.null_ls_ensure_installed or {},
|
opts = {
|
||||||
automatic_setup = true,
|
ensure_installed = pcode.null_ls_ensure_installed or {},
|
||||||
handlers = {},
|
automatic_setup = true,
|
||||||
|
handlers = {},
|
||||||
|
},
|
||||||
|
config = function(_, opts)
|
||||||
|
require("mason-null-ls").setup(opts)
|
||||||
|
end,
|
||||||
},
|
},
|
||||||
config = function(_, opts)
|
"nvimtools/none-ls-extras.nvim",
|
||||||
require("mason-null-ls").setup(opts)
|
|
||||||
end,
|
|
||||||
},
|
},
|
||||||
"nvimtools/none-ls-extras.nvim",
|
event = "InsertEnter",
|
||||||
|
opts = {},
|
||||||
|
config = true,
|
||||||
},
|
},
|
||||||
event = "InsertEnter",
|
}
|
||||||
opts = {},
|
end
|
||||||
config = true,
|
return M
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,126 +1,133 @@
|
||||||
return {
|
local M = {}
|
||||||
"mfussenegger/nvim-lint",
|
local disable = pcode.disable_null_ls or false
|
||||||
enabled = pcode.disable_null_ls or false,
|
if require("user.utils.cfgstatus").cheack() then
|
||||||
event = { "BufReadPre", "BufNewFile" },
|
disable = true
|
||||||
opts = function(_, opts)
|
end
|
||||||
local mason_reg = require("mason-registry")
|
if disable then
|
||||||
|
M = {
|
||||||
|
"mfussenegger/nvim-lint",
|
||||||
|
event = { "BufReadPre", "BufNewFile" },
|
||||||
|
opts = function(_, opts)
|
||||||
|
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
|
|
||||||
|
|
||||||
-- 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
|
||||||
end
|
|
||||||
|
|
||||||
if ignore[ftl] ~= pkg.spec.name then
|
-- if substring(pkg.spec.name, "eslint") then
|
||||||
opts.linters_by_ft[ftl] = opts.linters_by_ft[ftl] or {}
|
-- table.insert(listtest, ftl)
|
||||||
table.insert(opts.linters_by_ft[ftl], pkg.spec.name)
|
-- 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)
|
||||||
|
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
|
||||||
|
return M
|
||||||
|
|
23
lua/user/utils/cfgstatus.lua
Normal file
23
lua/user/utils/cfgstatus.lua
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
local M={}
|
||||||
|
|
||||||
|
M.cheack=function ()
|
||||||
|
local sts= false
|
||||||
|
if pcode.active_javascript_config.active or false then
|
||||||
|
sts=true
|
||||||
|
elseif pcode.active_rust_config or false then
|
||||||
|
sts=true
|
||||||
|
elseif pcode.active_php_config or false then
|
||||||
|
sts=true
|
||||||
|
elseif pcode.active_golang_config or false then
|
||||||
|
sts=true
|
||||||
|
elseif pcode.active_python_config or false then
|
||||||
|
sts=true
|
||||||
|
elseif pcode.active_cpp_config or false then
|
||||||
|
sts=true
|
||||||
|
elseif pcode.active_java_config.active or false then
|
||||||
|
sts=true
|
||||||
|
end
|
||||||
|
return sts
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
Loading…
Add table
Add a link
Reference in a new issue