add rest of plugins from previous config

This commit is contained in:
Alexander Navarro 2025-04-01 14:44:36 -03:00
parent 41327778ea
commit 93027a59a2
16 changed files with 697 additions and 1 deletions

View file

@ -0,0 +1,124 @@
return {
"stevearc/conform.nvim",
event = { "BufWritePre" },
cmd = { "ConformInfo" },
opts = {
-- log_level = vim.log.levels.DEBUG,
-- See aviable formatters in: https://github.com/stevearc/conform.nvim#formatters
-- Formatters can be installed by mason
formatters_by_ft = {
-- Conform will run multiple formatters sequentially
-- Use a stop_after_first = true to run only the first available formatter
-- Use the "_" filetype to run formatters on filetypes that don't
-- have other formatters configured.
["_"] = { "trim_whitespace" },
blade = { "blade-formatter" },
css = { "biome" },
go = { "gofumpt", "goimports_reviser", "golines" },
html = { "djlint", "prettierd", stop_after_first = true },
htmldjango = { "djlint", stop_after_first = true },
javascript = { "biome" },
javascriptreact = { "biome" },
json = { "biome" },
jsonc = { "biome" },
lua = { "stylua" },
markdown = { "markdownlint" },
nim = { "nimpretty" },
php = { "pint" },
python = { "ruff_format", "ruff_organize_imports" },
scss = { "prettierd", "prettier", stop_after_first = true },
sh = { "shfmt" },
toml = { "taplo" },
typescript = { "biome" },
typescriptreact = { "biome" },
xml = { "lemminx" },
zsh = { "shfmt" },
sql = { "sleek" }
},
formatters = {
djlint = {
prepend_args = {
"--format-css",
"--indent-css",
"2",
"--format-js",
"--indent-js",
"2",
"--indent",
"2",
"--preserve-blank-lines",
"--quiet"
}
}
},
format_on_save = function(bufnr)
-- Disable with a global or buffer-local variable
if vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat then
return
end
return { timeout_ms = 2000, lsp_fallback = true }
end,
},
config = function(_, opts)
require("conform").setup(opts)
local function toggleAutoFormat()
-- to make this global, change b to g
if vim.b.disable_autoformat == nil then
vim.b.disable_autoformat = true
print("Autoformat set to: " .. tostring(not vim.b.disable_autoformat))
return
end
vim.b.disable_autoformat = not vim.b.disable_autoformat
print("Autoformat set to: " .. tostring(not vim.b.disable_autoformat))
end
MAP("n", "<leader>uf", toggleAutoFormat, "Toggle auto format")
vim.api.nvim_create_user_command("Fmt", function(args)
local range = nil
if args.count ~= -1 then
local end_line = vim.api.nvim_buf_get_lines(0, args.line2 - 1, args.line2, true)[1]
range = {
start = { args.line1, 0 },
["end"] = { args.line2, end_line:len() },
}
end
local function callback(err, did_edit)
if not did_edit then
vim.notify("The file was not formatted:\n" .. tostring(err), vim.log.levels.ERROR)
return
end
if args.bang then
vim.cmd("w")
end
end
require("conform").format(
{
async = true,
lsp_format = "fallback",
range = range,
formatters = args.fargs
},
callback
)
end, {
range = true,
bang = true,
force = true,
desc = "Format the document",
nargs = '*',
-- complete = function()
-- local formatters = require('conform').formatters_by_ft
--
-- return vim.tbl_keys(formatters)
-- end
})
end,
}