mirror of
https://github.com/pojokcodeid/nvim-lazy.git
synced 2025-06-21 08:35:48 +02:00
add alternative formatter & linter conform and nvim-lint
This commit is contained in:
parent
98a141b4b5
commit
2486c9e49e
5 changed files with 195 additions and 5 deletions
|
@ -12,26 +12,25 @@
|
||||||
"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" },
|
||||||
"dracula.nvim": { "branch": "main", "commit": "8d8bddb8814c3e7e62d80dda65a9876f97eb699c" },
|
"dracula.nvim": { "branch": "main", "commit": "8d8bddb8814c3e7e62d80dda65a9876f97eb699c" },
|
||||||
"dressing.nvim": { "branch": "master", "commit": "71349f24c6e07b39f33600985843c289ca735308" },
|
"dressing.nvim": { "branch": "master", "commit": "71349f24c6e07b39f33600985843c289ca735308" },
|
||||||
|
"fidget.nvim": { "branch": "main", "commit": "0ba1e16d07627532b6cae915cc992ecac249fb97" },
|
||||||
"friendly-snippets": { "branch": "main", "commit": "682157939e57bd6a2c86277dfd4d6fbfce63dbac" },
|
"friendly-snippets": { "branch": "main", "commit": "682157939e57bd6a2c86277dfd4d6fbfce63dbac" },
|
||||||
"gitsigns.nvim": { "branch": "main", "commit": "0b04035bb7b3c83e999b9676e2fb46fd0aa9f910" },
|
"gitsigns.nvim": { "branch": "main", "commit": "0b04035bb7b3c83e999b9676e2fb46fd0aa9f910" },
|
||||||
"indent-blankline.nvim": { "branch": "master", "commit": "4288ce8128a52650e401dda42fd7651a6038f262" },
|
"indent-blankline.nvim": { "branch": "master", "commit": "4288ce8128a52650e401dda42fd7651a6038f262" },
|
||||||
"lazy.nvim": { "branch": "main", "commit": "69041bccb70f68408633e93ed33012ee18889bb0" },
|
"lazy.nvim": { "branch": "main", "commit": "69041bccb70f68408633e93ed33012ee18889bb0" },
|
||||||
"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": { "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" },
|
||||||
"noice.nvim": { "branch": "main", "commit": "d580646db85f49b8226d52b143a458161f41954a" },
|
"noice.nvim": { "branch": "main", "commit": "d580646db85f49b8226d52b143a458161f41954a" },
|
||||||
"none-ls-extras.nvim": { "branch": "main", "commit": "336e84b9e43c0effb735b08798ffac382920053b" },
|
|
||||||
"none-ls.nvim": { "branch": "main", "commit": "f1b438ab1709cf9d8875843559d20265013ac755" },
|
|
||||||
"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" },
|
||||||
"nvim-colorizer.lua": { "branch": "master", "commit": "85855b38011114929f4058efc97af1059ab3e41d" },
|
"nvim-colorizer.lua": { "branch": "master", "commit": "85855b38011114929f4058efc97af1059ab3e41d" },
|
||||||
|
"nvim-lint": { "branch": "master", "commit": "941fa1220a61797a51f3af9ec6b7d74c8c7367ce" },
|
||||||
"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" },
|
||||||
|
|
|
@ -42,6 +42,11 @@ pcode.show_mode = 3
|
||||||
pcode.format_on_save = 1
|
pcode.format_on_save = 1
|
||||||
pcode.format_timeout_ms = 5000
|
pcode.format_timeout_ms = 5000
|
||||||
|
|
||||||
|
-- https://github.com/mfussenegger/nvim-lint
|
||||||
|
-- https://github.com/stevearc/conform.nvim
|
||||||
|
-- use conform and nvim-lint if set true
|
||||||
|
pcode.disable_null_ls = false
|
||||||
|
|
||||||
pcode.treesitter_ensure_installed = {}
|
pcode.treesitter_ensure_installed = {}
|
||||||
|
|
||||||
-- ini hanya untuk lsp yg tidak support masson
|
-- ini hanya untuk lsp yg tidak support masson
|
||||||
|
|
93
lua/plugins/conform.lua
Normal file
93
lua/plugins/conform.lua
Normal file
|
@ -0,0 +1,93 @@
|
||||||
|
return {
|
||||||
|
"stevearc/conform.nvim",
|
||||||
|
enabled = pcode.disable_null_ls or false,
|
||||||
|
event = { "BufReadPre", "BufNewFile" },
|
||||||
|
opts = function()
|
||||||
|
local mason_reg = require("mason-registry")
|
||||||
|
|
||||||
|
local formatters = {}
|
||||||
|
local formatters_by_ft = {}
|
||||||
|
|
||||||
|
-- add diff langue vs filetype
|
||||||
|
local keymap = {
|
||||||
|
["c++"] = "cpp",
|
||||||
|
["c#"] = "cs",
|
||||||
|
}
|
||||||
|
|
||||||
|
-- add dif conform vs mason
|
||||||
|
local name_map = {
|
||||||
|
["cmakelang"] = "cmake_format",
|
||||||
|
["deno"] = "deno_fmt",
|
||||||
|
["elm-format"] = "elm_format",
|
||||||
|
["gdtoolkit"] = "gdformat",
|
||||||
|
["nixpkgs-fmt"] = "nixpkgs_fmt",
|
||||||
|
["opa"] = "opa_fmt",
|
||||||
|
["php-cs-fixer"] = "php_cs_fixer",
|
||||||
|
["ruff"] = "ruff_format",
|
||||||
|
["sql-formatter"] = "sql_formatter",
|
||||||
|
["xmlformatter"] = "xmlformat",
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, pkg in pairs(mason_reg.get_installed_packages()) do
|
||||||
|
for _, type in pairs(pkg.spec.categories) do
|
||||||
|
-- only act upon a formatter
|
||||||
|
if type == "Formatter" then
|
||||||
|
-- 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
|
||||||
|
-- the key of the entry to this table
|
||||||
|
-- is the name of the bare executable
|
||||||
|
-- the actual value may not be the absolute path
|
||||||
|
-- in some cases
|
||||||
|
local bin = next(pkg.spec.bin)
|
||||||
|
-- this should be replaced by a function
|
||||||
|
-- that quieries the configured mason install path
|
||||||
|
local prefix = vim.fn.stdpath("data") .. "/mason/bin/"
|
||||||
|
|
||||||
|
formatters[pkg.spec.name] = {
|
||||||
|
command = prefix .. bin,
|
||||||
|
args = { "$FILENAME" },
|
||||||
|
stdin = true,
|
||||||
|
require_cwd = false,
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
-- finally add the formatter to it's compatible filetype(s)
|
||||||
|
for _, ft in pairs(pkg.spec.languages) do
|
||||||
|
local ftl = string.lower(ft)
|
||||||
|
local ready = mason_reg.get_package(pkg.spec.name):is_installed()
|
||||||
|
if ready then
|
||||||
|
if keymap[ftl] ~= nil then
|
||||||
|
ftl = keymap[ftl]
|
||||||
|
end
|
||||||
|
if name_map[pkg.spec.name] ~= nil then
|
||||||
|
pkg.spec.name = name_map[pkg.spec.name]
|
||||||
|
end
|
||||||
|
formatters_by_ft[ftl] = formatters_by_ft[ftl] or {}
|
||||||
|
table.insert(formatters_by_ft[ftl], pkg.spec.name)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return {
|
||||||
|
format_on_save = {
|
||||||
|
lsp_fallback = true,
|
||||||
|
timeout_ms = pcode.format_timeout_ms or 5000,
|
||||||
|
},
|
||||||
|
formatters = formatters,
|
||||||
|
formatters_by_ft = formatters_by_ft,
|
||||||
|
}
|
||||||
|
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,
|
||||||
|
}
|
|
@ -2,7 +2,7 @@ return {
|
||||||
{
|
{
|
||||||
"nvimtools/none-ls.nvim",
|
"nvimtools/none-ls.nvim",
|
||||||
lazy = true,
|
lazy = true,
|
||||||
enabled = false,
|
enabled = not (pcode.disable_null_ls or false),
|
||||||
dependencies = {
|
dependencies = {
|
||||||
{
|
{
|
||||||
"jayp0521/mason-null-ls.nvim",
|
"jayp0521/mason-null-ls.nvim",
|
||||||
|
|
93
lua/plugins/nvimlint.lua
Normal file
93
lua/plugins/nvimlint.lua
Normal file
|
@ -0,0 +1,93 @@
|
||||||
|
return {
|
||||||
|
"mfussenegger/nvim-lint",
|
||||||
|
enabled = pcode.disable_null_ls or false,
|
||||||
|
event = { "BufReadPre", "BufNewFile" },
|
||||||
|
opts = function(_, opts)
|
||||||
|
local mason_reg = require("mason-registry")
|
||||||
|
|
||||||
|
opts.linters_by_ft = opts.linters_by_ft or {}
|
||||||
|
|
||||||
|
-- add diff langue vs filetype
|
||||||
|
local keymap = {
|
||||||
|
["c++"] = "cpp",
|
||||||
|
["c#"] = "cs",
|
||||||
|
}
|
||||||
|
|
||||||
|
-- add dif conform vs mason
|
||||||
|
local name_map = {
|
||||||
|
["actionlint"] = "actionlint",
|
||||||
|
["ansible_lint"] = "ansible_lint",
|
||||||
|
["buf"] = "buf_lint",
|
||||||
|
["buildifier"] = "buildifier",
|
||||||
|
["cfn-lint"] = "cfn_lint",
|
||||||
|
["checkstyle"] = "checkstyle",
|
||||||
|
["clj-kondo"] = "clj_kondo",
|
||||||
|
["cmakelint"] = "cmakelint",
|
||||||
|
["codespell"] = "codespell",
|
||||||
|
["cpplint"] = "cpplint",
|
||||||
|
["cspell"] = "cspell",
|
||||||
|
["curlylint"] = "curlylint",
|
||||||
|
["djlint"] = "djlint",
|
||||||
|
["erb-lint"] = "erb_lint",
|
||||||
|
["eslint_d"] = "eslint_d",
|
||||||
|
["flake8"] = "flake8",
|
||||||
|
["gdtoolkit"] = "gdlint",
|
||||||
|
["golangci-lint"] = "golangcilint",
|
||||||
|
["hadolint"] = "hadolint",
|
||||||
|
["jsonlint"] = "jsonlint",
|
||||||
|
["ktlint"] = "ktlint",
|
||||||
|
["luacheck"] = "luacheck",
|
||||||
|
["markdownlint"] = "markdownlint",
|
||||||
|
["mypy"] = "mypy",
|
||||||
|
["phpcs"] = "phpcs",
|
||||||
|
["phpmd"] = "phpmd",
|
||||||
|
["phpstan"] = "phpstan",
|
||||||
|
["proselint"] = "proselint",
|
||||||
|
["pydocstyle"] = "pydocstyle",
|
||||||
|
["pylint"] = "pylint",
|
||||||
|
["revive"] = "revive",
|
||||||
|
["rstcheck"] = "rstcheck",
|
||||||
|
["rubocop"] = "rubocop",
|
||||||
|
["ruff"] = "ruff",
|
||||||
|
["selene"] = "selene",
|
||||||
|
["shellcheck"] = "shellcheck",
|
||||||
|
["sqlfluff"] = "sqlfluff",
|
||||||
|
["standardrb"] = "standardrb",
|
||||||
|
["stylelint"] = "stylelint",
|
||||||
|
["solhint"] = "solhint",
|
||||||
|
["tflint"] = "tflint",
|
||||||
|
["tfsec"] = "tfsec",
|
||||||
|
["trivy"] = "trivy",
|
||||||
|
["vale"] = "vale",
|
||||||
|
["vint"] = "vint",
|
||||||
|
["vulture"] = "vulture",
|
||||||
|
["yamllint"] = "yamllint",
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, pkg in pairs(mason_reg.get_installed_packages()) do
|
||||||
|
for _, type in pairs(pkg.spec.categories) do
|
||||||
|
-- only act upon a formatter
|
||||||
|
if type == "Linter" then
|
||||||
|
-- finally add the formatter to it's compatible filetype(s)
|
||||||
|
for _, ft in pairs(pkg.spec.languages) do
|
||||||
|
local ftl = string.lower(ft)
|
||||||
|
local ready = mason_reg.get_package(pkg.spec.name):is_installed()
|
||||||
|
if ready then
|
||||||
|
if keymap[ftl] ~= nil then
|
||||||
|
ftl = keymap[ftl]
|
||||||
|
end
|
||||||
|
if name_map[pkg.spec.name] ~= nil then
|
||||||
|
pkg.spec.name = name_map[pkg.spec.name]
|
||||||
|
end
|
||||||
|
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,
|
||||||
|
config = function(_, opts)
|
||||||
|
require("lint").linters_by_ft = opts.linters_by_ft
|
||||||
|
end,
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue