Files
2026-11-13 00:08:06 +01:00

52 lines
1.4 KiB
Lua

return {
{
"stevearc/conform.nvim",
cond = vim.g.profile == "full",
event = "BufWritePre",
cmd = "ConformInfo",
keys = {
{
"<leader>lf",
function()
require("conform").format({ async = true, lsp_format = "fallback" })
end,
desc = "Format buffer",
},
{
"<leader>tF",
function()
vim.b.disable_autoformat = not vim.b.disable_autoformat
vim.notify("format on save: " .. (vim.b.disable_autoformat and "off" or "on"))
end,
desc = "Toggle format on save (buffer)",
},
},
opts = {
formatters_by_ft = {
nix = { "nixfmt" },
lua = { "stylua" },
sh = { "shfmt" },
bash = { "shfmt" },
yaml = { "prettierd" },
json = { "jq" },
jsonc = { "prettierd" },
markdown = { "prettierd" },
rust = { "rustfmt" },
go = { "goimports", "gofumpt" },
javascript = { "prettierd" },
javascriptreact = { "prettierd" },
typescript = { "prettierd" },
typescriptreact = { "prettierd" },
python = { "ruff_format" },
php = { "php_cs_fixer" },
},
format_on_save = function(buf)
if vim.b[buf].disable_autoformat or vim.b[buf].bigfile then
return
end
return { timeout_ms = 1000, lsp_format = "fallback" }
end,
},
},
}