return { { "stevearc/conform.nvim", opts = { format_on_save = function(bufnr) if vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat then return end return { timeout_ms = 500, lsp_format = "fallback" } end, formatters_by_ft = { ["_"] = { "trim_whitespace" }, bash = { "shellcheck", "shellharden", "shfmt" }, c = { "clang_format" }, cmake = { "cmake_format" }, cpp = { "clang_format" }, css = { "prettierd", "prettier", stop_after_first = true }, html = { "prettierd", "prettier", stop_after_first = true }, javascript = { "prettierd", "prettier", stop_after_first = true }, json = { "jq" }, lua = { "stylua" }, markdown = { "prettierd", "prettier", stop_after_first = true }, nix = { "nixfmt" }, python = { "black" }, rust = { "rustfmt" }, typescript = { "prettierd", "prettier", stop_after_first = true }, yaml = { "prettierd", "prettier", stop_after_first = true }, }, notify_on_error = true, }, init = function() vim.api.nvim_create_user_command("FormatToggle", function(args) if args.bang then vim.b.disable_autoformat = not vim.b.disable_autoformat else vim.g.disable_autoformat = not vim.g.disable_autoformat end end, { bang = true, desc = "Toggle autoformat on save" }) end, }, }