Something went wrong. Try again.
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061vim.pack.add { "https://github.com/stevearc/conform.nvim" }
local conform = require("conform")conform.setup { notify_on_error = false, 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 = 500, lsp_fallback = "fallback" } end,}conform.formatters_by_ft = { lua = { "stylua" }, python = { "ruff_format", "ruff_organize_imports" }, javascript = { "oxfmt", "biome", "prettierd", "prettier", stop_after_first = true }, typescript = { "oxfmt", "biome", "prettierd", "prettier", stop_after_first = true }, svelte = { "prettierd", "prettier", stop_after_first = true }, json = { "biome" }, jsonc = { "biome" }, html = { "prettierd", "prettier", stop_after_first = true }, css = { "biome", "prettierd", "prettier", stop_after_first = true }, scss = { "prettierd", "prettier", stop_after_first = true }, rust = { lsp_format = "fallback" }, typst = { "typstyle" }, toml = { "taplo" }, nix = { "nixfmt" }, zig = { "zigfmt" }, c = { "clang-format" }, cpp = { "clang-format" }, hpp = { "clang-format" }, bash = { "shfmt" }, ebuild = { "shfmt" }, markdown = { "mdformat" }, wgsl = { lsp_format = "prefer" }, tex = { "tex-fmt" }, -- quarto = { "injected", "mdformat" },}
vim.keymap.set("n", "grf", function() conform.format { async = true, lsp_fallback = true } end, { desc = "Format",})vim.api.nvim_create_user_command( "ConformDisable", function() vim.g.disable_autoformat = true end, {})vim.api.nvim_create_user_command( "ConformEnable", function(_) vim.g.disable_autoformat = false end, {})vim.api.nvim_create_user_command("ConformDisableBuf", function(_) local bufnr = vim.api.nvim_get_current_buf() vim.b[bufnr].disable_autoformat = trueend, {})
vim.api.nvim_create_user_command("ConformEnableBuf", function(_) local bufnr = vim.api.nvim_get_current_buf() vim.b[bufnr].disable_autoformat = falseend, {})