♻️ refactor(nvim): move some formatters and linters into their respective lang extra

This commit is contained in:
Sergio Laín 2024-01-12 01:02:15 +01:00
parent 865d89c1f8
commit 602cc73217
No known key found for this signature in database
GPG key ID: 14C9B8080681777B
14 changed files with 96 additions and 143 deletions

View file

@ -186,6 +186,7 @@
- [monaqa/dial.nvim](https://dotfyle.com/plugins/monaqa/dial.nvim) - [monaqa/dial.nvim](https://dotfyle.com/plugins/monaqa/dial.nvim)
- [chrisgrieser/nvim-various-textobjs](https://dotfyle.com/plugins/chrisgrieser/nvim-various-textobjs) - [chrisgrieser/nvim-various-textobjs](https://dotfyle.com/plugins/chrisgrieser/nvim-various-textobjs)
- [johmsalas/text-case.nvim](https://dotfyle.com/plugins/johmsalas/text-case.nvim)
- [ckolkey/ts-node-action](https://dotfyle.com/plugins/ckolkey/ts-node-action) - [ckolkey/ts-node-action](https://dotfyle.com/plugins/ckolkey/ts-node-action)
- [debugloop/telescope-undo.nvim](https://dotfyle.com/plugins/debugloop/telescope-undo.nvim) - [debugloop/telescope-undo.nvim](https://dotfyle.com/plugins/debugloop/telescope-undo.nvim)
- [echasnovski/mini.pairs](https://dotfyle.com/plugins/echasnovski/mini.pairs) - [echasnovski/mini.pairs](https://dotfyle.com/plugins/echasnovski/mini.pairs)

View file

@ -43,8 +43,6 @@
"plugins.extras.editor.telescope.zoxide", "plugins.extras.editor.telescope.zoxide",
"plugins.extras.editor.terminal.floaterm", "plugins.extras.editor.terminal.floaterm",
"plugins.extras.formatting.prettier-extended", "plugins.extras.formatting.prettier-extended",
"plugins.extras.formatting.ruff",
"plugins.extras.formatting.rustfmt",
"plugins.extras.formatting.trim_newlines", "plugins.extras.formatting.trim_newlines",
"plugins.extras.formatting.trim_whitespace", "plugins.extras.formatting.trim_whitespace",
"plugins.extras.lang.ansible", "plugins.extras.lang.ansible",
@ -59,7 +57,6 @@
"plugins.extras.linting.biome", "plugins.extras.linting.biome",
"plugins.extras.linting.cspell", "plugins.extras.linting.cspell",
"plugins.extras.linting.eslint-extended", "plugins.extras.linting.eslint-extended",
"plugins.extras.linting.shellcheck",
"plugins.extras.lsp.actions-preview", "plugins.extras.lsp.actions-preview",
"plugins.extras.lsp.file-operations", "plugins.extras.lsp.file-operations",
"plugins.extras.lsp.garbage-day", "plugins.extras.lsp.garbage-day",

View file

@ -1,17 +0,0 @@
return {
{
"stevearc/conform.nvim",
opts = function(_, opts)
opts.formatters_by_ft.python = opts.formatters_by_ft.python or {}
table.insert(opts.formatters_by_ft.python, "ruff_format")
return opts
end,
},
{
"williamboman/mason.nvim",
opts = function(_, opts)
opts.ensure_installed = opts.ensure_installed or {}
vim.list_extend(opts.ensure_installed, { "ruff-lsp" })
end,
},
}

View file

@ -1,8 +0,0 @@
return {
"stevearc/conform.nvim",
opts = function(_, opts)
opts.formatters_by_ft.rust = opts.formatters_by_ft.rust or {}
table.insert(opts.formatters_by_ft.rust, "rustfmt")
return opts
end,
}

View file

@ -9,8 +9,6 @@ return {
{ {
"stevearc/conform.nvim", "stevearc/conform.nvim",
opts = function(_, opts) 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) local function add_formatters(tbl)
for ft, formatters in pairs(tbl) do for ft, formatters in pairs(tbl) do
if opts.formatters_by_ft[ft] == nil then if opts.formatters_by_ft[ft] == nil then

View file

@ -1,31 +0,0 @@
return {
{
"williamboman/mason.nvim",
opts = function(_, opts)
opts.ensure_installed = opts.ensure_installed or {}
vim.list_extend(opts.ensure_installed, { "sqlfmt" })
end,
},
{
"stevearc/conform.nvim",
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({
["sql"] = { "sqlfmt" },
["plsql"] = { "sqlfmt" },
["mysql"] = { "sqlfmt" },
})
end,
},
}

View file

@ -19,7 +19,15 @@ return {
"williamboman/mason.nvim", "williamboman/mason.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, { "bash-language-server" }) vim.list_extend(opts.ensure_installed, { "bash-language-server", "shellcheck" })
end,
},
{
"mfussenegger/nvim-lint",
opts = function(_, opts)
opts.linters_by_ft.bash = opts.linters_by_ft.bash or {}
table.insert(opts.linters_by_ft.bash, "shellcheck")
return opts
end, end,
}, },
{ {

View file

@ -1,5 +1,12 @@
return { return {
{ import = "lazyvim.plugins.extras.lang.go" }, { import = "lazyvim.plugins.extras.lang.go" },
{
"williamboman/mason.nvim",
opts = function(_, opts)
opts.ensure_installed = opts.ensure_installed or {}
vim.list_extend(opts.ensure_installed, { "golangcil-lint" })
end,
},
{ {
"ray-x/go.nvim", "ray-x/go.nvim",
dependencies = { dependencies = {
@ -10,7 +17,31 @@ return {
opts = {}, opts = {},
event = { "LazyFile" }, event = { "LazyFile" },
ft = { "go", "gomod" }, ft = { "go", "gomod" },
build = ':lua require("go.install").update_all_sync()', build = function()
require("go.install").update_all_sync()
end,
},
{
"mfussenegger/nvim-lint",
opts = function(_, opts)
local function add_linters(tbl)
for ft, linters in pairs(tbl) do
if opts.linters_by_ft[ft] == nil then
opts.linters_by_ft[ft] = linters
else
vim.list_extend(opts.linters_by_ft[ft], linters)
end
end
end
add_linters({
["go"] = { "golangcilint" },
["gomod"] = { "golangcilint" },
["gowork"] = { "golangcilint" },
})
return opts
end,
}, },
{ {
"luckasRanarison/nvim-devdocs", "luckasRanarison/nvim-devdocs",

View file

@ -1,5 +1,13 @@
return { return {
{ import = "lazyvim.plugins.extras.lang.python" }, { import = "lazyvim.plugins.extras.lang.python" },
{
"stevearc/conform.nvim",
opts = function(_, opts)
opts.formatters_by_ft.python = opts.formatters_by_ft.python or {}
table.insert(opts.formatters_by_ft.python, "ruff_format")
return opts
end,
},
{ {
"luckasRanarison/nvim-devdocs", "luckasRanarison/nvim-devdocs",
optional = true, optional = true,

View file

@ -67,6 +67,9 @@ return {
opts = function(_, opts) opts = function(_, opts)
opts.formatters_by_ft.toml = opts.formatters_by_ft.toml or {} opts.formatters_by_ft.toml = opts.formatters_by_ft.toml or {}
table.insert(opts.formatters_by_ft.toml, "taplo") table.insert(opts.formatters_by_ft.toml, "taplo")
opts.formatters_by_ft.rust = opts.formatters_by_ft.rust or {}
table.insert(opts.formatters_by_ft.rust, "rustfmt")
return opts return opts
end, end,
}, },

View file

@ -73,7 +73,7 @@ return {
"williamboman/mason.nvim", "williamboman/mason.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, { "sqlls" }) vim.list_extend(opts.ensure_installed, { "sqlls", "sqlfmt", "sqlfluff" })
end, end,
}, },
{ {
@ -84,6 +84,48 @@ return {
}, },
}, },
}, },
{
"mfussenegger/nvim-lint",
opts = function(_, opts)
local function add_linters(tbl)
for ft, linters in pairs(tbl) do
if opts.linters_by_ft[ft] == nil then
opts.linters_by_ft[ft] = linters
else
vim.list_extend(opts.linters_by_ft[ft], linters)
end
end
end
add_linters({
["sql"] = { "sqlfluff" },
["plsql"] = { "sqlfluff" },
["mysql"] = { "sqlfluff" },
})
return opts
end,
},
{
"stevearc/conform.nvim",
opts = function(_, opts)
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({
["sql"] = { "sqlfmt" },
["plsql"] = { "sqlfmt" },
["mysql"] = { "sqlfmt" },
})
end,
},
{ {
"luckasRanarison/nvim-devdocs", "luckasRanarison/nvim-devdocs",
optional = true, optional = true,

View file

@ -1,31 +0,0 @@
return {
{
"williamboman/mason.nvim",
opts = function(_, opts)
opts.ensure_installed = opts.ensure_installed or {}
vim.list_extend(opts.ensure_installed, { "golangcil-lint" })
end,
},
{
"mfussenegger/nvim-lint",
opts = function(_, opts)
local function add_linters(tbl)
for ft, linters in pairs(tbl) do
if opts.linters_by_ft[ft] == nil then
opts.linters_by_ft[ft] = linters
else
vim.list_extend(opts.linters_by_ft[ft], linters)
end
end
end
add_linters({
["go"] = { "golangcilint" },
["gomod"] = { "golangcilint" },
["gowork"] = { "golangcilint" },
})
return opts
end,
},
}

View file

@ -1,17 +0,0 @@
return {
{
"williamboman/mason.nvim",
opts = function(_, opts)
opts.ensure_installed = opts.ensure_installed or {}
vim.list_extend(opts.ensure_installed, { "shellcheck" })
end,
},
{
"mfussenegger/nvim-lint",
opts = function(_, opts)
opts.linters_by_ft.bash = opts.linters_by_ft.bash or {}
table.insert(opts.linters_by_ft.bash, "shellcheck")
return opts
end,
},
}

View file

@ -1,31 +0,0 @@
return {
{
"williamboman/mason.nvim",
opts = function(_, opts)
opts.ensure_installed = opts.ensure_installed or {}
vim.list_extend(opts.ensure_installed, { "sqlfluff" })
end,
},
{
"mfussenegger/nvim-lint",
opts = function(_, opts)
local function add_linters(tbl)
for ft, linters in pairs(tbl) do
if opts.linters_by_ft[ft] == nil then
opts.linters_by_ft[ft] = linters
else
vim.list_extend(opts.linters_by_ft[ft], linters)
end
end
end
add_linters({
["sql"] = { "sqlfluff" },
["plsql"] = { "sqlfluff" },
["mysql"] = { "sqlfluff" },
})
return opts
end,
},
}