mirror of
https://github.com/LazyVim/LazyVim.git
synced 2026-07-25 14:01:06 +00:00
fix(extras): Extend formatters/linters dynamically
This commit is contained in:
parent
68ff818a5b
commit
6de5b19a1b
9 changed files with 72 additions and 52 deletions
|
|
@ -17,10 +17,10 @@ return {
|
|||
{
|
||||
"stevearc/conform.nvim",
|
||||
optional = true,
|
||||
opts = {
|
||||
formatters_by_ft = {
|
||||
["python"] = { "black" },
|
||||
},
|
||||
},
|
||||
opts = function(_, opts)
|
||||
opts.formatters_by_ft.python = opts.formatters_by_ft.python or {}
|
||||
table.insert(opts.formatters_by_ft.python, "black")
|
||||
return opts
|
||||
end,
|
||||
},
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,8 +17,20 @@ return {
|
|||
{
|
||||
"stevearc/conform.nvim",
|
||||
optional = true,
|
||||
opts = {
|
||||
formatters_by_ft = {
|
||||
opts = function(_, opts)
|
||||
--- Extend the conform plugin config and add given formatters
|
||||
---@param tbl table<string, conform.FormatterUnit[]> Table of filetype to formatters mappings
|
||||
local function add_formatters(tbl)
|
||||
for ft, formatters in pairs(tbl) do
|
||||
if opts.formatters_by_ft[ft] == nil then
|
||||
opts.formatters_by_ft[ft] = formatters
|
||||
else
|
||||
vim.list_extend(opts.formatters_by_ft[ft], formatters)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
add_formatters({
|
||||
["javascript"] = { "prettier" },
|
||||
["javascriptreact"] = { "prettier" },
|
||||
["typescript"] = { "prettier" },
|
||||
|
|
@ -35,7 +47,7 @@ return {
|
|||
["markdown.mdx"] = { "prettier" },
|
||||
["graphql"] = { "prettier" },
|
||||
["handlebars"] = { "prettier" },
|
||||
},
|
||||
},
|
||||
})
|
||||
end,
|
||||
},
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,11 +20,11 @@ return {
|
|||
{
|
||||
"mfussenegger/nvim-lint",
|
||||
optional = true,
|
||||
opts = {
|
||||
linters_by_ft = {
|
||||
cmake = { "cmakelint" },
|
||||
},
|
||||
},
|
||||
opts = function(_, opts)
|
||||
opts.linters_by_ft.cmake = opts.linters_by_ft.cmake or {}
|
||||
table.insert(opts.linters_by_ft.cmake, "cmakelint")
|
||||
return opts
|
||||
end,
|
||||
},
|
||||
{
|
||||
"mason.nvim",
|
||||
|
|
|
|||
|
|
@ -27,11 +27,11 @@ return {
|
|||
{
|
||||
"mfussenegger/nvim-lint",
|
||||
optional = true,
|
||||
opts = {
|
||||
linters_by_ft = {
|
||||
dockerfile = { "hadolint" },
|
||||
},
|
||||
},
|
||||
opts = function(_, opts)
|
||||
opts.linters_by_ft.dockerfile = opts.linters_by_ft.dockerfile or {}
|
||||
table.insert(opts.linters_by_ft.dockerfile, "hadolint")
|
||||
return opts
|
||||
end,
|
||||
},
|
||||
{
|
||||
"neovim/nvim-lspconfig",
|
||||
|
|
|
|||
|
|
@ -49,9 +49,10 @@ return {
|
|||
if vim.fn.executable("credo") == 0 then
|
||||
return
|
||||
end
|
||||
opts.linters_by_ft = {
|
||||
elixir = { "credo" },
|
||||
}
|
||||
|
||||
opts.linters_by_ft.elixir = opts.linters_by_ft.elixir or {}
|
||||
table.insert(opts.linters_by_ft.elixir, "credo")
|
||||
return opts
|
||||
end,
|
||||
},
|
||||
}
|
||||
|
|
|
|||
|
|
@ -114,11 +114,11 @@ return {
|
|||
{
|
||||
"stevearc/conform.nvim",
|
||||
optional = true,
|
||||
opts = {
|
||||
formatters_by_ft = {
|
||||
go = { "goimports", "gofumpt" },
|
||||
},
|
||||
},
|
||||
opts = function(_, opts)
|
||||
opts.formatters_by_ft.go = opts.formatters_by_ft.go or {}
|
||||
vim.table_extend(opts.formatters_by_ft.go, { "goimports", "gofumpt" })
|
||||
return opts
|
||||
end,
|
||||
},
|
||||
{
|
||||
"mfussenegger/nvim-dap",
|
||||
|
|
|
|||
|
|
@ -27,11 +27,11 @@ return {
|
|||
{
|
||||
"mfussenegger/nvim-lint",
|
||||
optional = true,
|
||||
opts = {
|
||||
linters_by_ft = {
|
||||
markdown = { "markdownlint" },
|
||||
},
|
||||
},
|
||||
opts = function(_, opts)
|
||||
opts.linters_by_ft.markdown = opts.linters_by_ft.markdown or {}
|
||||
table.insert(opts.linters_by_ft.markdown, "markdownlint")
|
||||
return opts
|
||||
end,
|
||||
},
|
||||
{
|
||||
"neovim/nvim-lspconfig",
|
||||
|
|
|
|||
|
|
@ -20,17 +20,18 @@ return {
|
|||
{
|
||||
"stevearc/conform.nvim",
|
||||
optional = true,
|
||||
opts = {
|
||||
formatters_by_ft = {
|
||||
cs = { "csharpier" },
|
||||
},
|
||||
formatters = {
|
||||
opts = function(_, opts)
|
||||
opts.formatters_by_ft.cs = opts.formatters_by_ft.cs or {}
|
||||
table.insert(opts.formatters_by_ft.cs, "csharpier")
|
||||
|
||||
opts.formatters = {
|
||||
csharpier = {
|
||||
command = "dotnet-csharpier",
|
||||
args = { "--write-stdout" },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
return opts
|
||||
end,
|
||||
},
|
||||
{
|
||||
"williamboman/mason.nvim",
|
||||
|
|
|
|||
|
|
@ -38,22 +38,28 @@ return {
|
|||
{
|
||||
"mfussenegger/nvim-lint",
|
||||
optional = true,
|
||||
opts = {
|
||||
linters_by_ft = {
|
||||
terraform = { "terraform_validate" },
|
||||
tf = { "terraform_validate" },
|
||||
},
|
||||
},
|
||||
opts = function(_, opts)
|
||||
opts.linters_by_ft.terraform = opts.linters_by_ft.terraform or {}
|
||||
table.insert(opts.linters_by_ft.terraform, "terraform_validate")
|
||||
|
||||
opts.linters_by_ft.tf = opts.linters_by_ft.tf or {}
|
||||
table.insert(opts.linters_by_ft.tf, "terraform_validate")
|
||||
return opts
|
||||
end,
|
||||
},
|
||||
{
|
||||
"stevearc/conform.nvim",
|
||||
optional = true,
|
||||
opts = {
|
||||
formatters_by_ft = {
|
||||
terraform = { "terraform_fmt" },
|
||||
tf = { "terraform_fmt" },
|
||||
["terraform-vars"] = { "terraform_fmt" },
|
||||
},
|
||||
},
|
||||
opts = function(_, opts)
|
||||
opts.formatters_by_ft.terraform = opts.formatters_by_ft.terraform or {}
|
||||
table.insert(opts.formatters_by_ft.terraform, "terraform_fmt")
|
||||
|
||||
opts.formatters_by_ft.tf = opts.formatters_by_ft.tf or {}
|
||||
table.insert(opts.formatters_by_ft.tf, "terraform_fmt")
|
||||
|
||||
opts.formatters_by_ft["terraform-vars"] = opts.formatters_by_ft["terraform-vars"] or {}
|
||||
table.insert(opts.formatters_by_ft["terraform-vars"], "terraform_fmt")
|
||||
return opts
|
||||
end,
|
||||
},
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue