return { "stevearc/conform.nvim", event = { "BufReadPre", "BufNewFile" }, config = function() local conform = require("conform") conform.setup({ formatters_by_ft = { -- Web development javascript = { "prettier" }, typescript = { "prettier" }, javascriptreact = { "prettier" }, typescriptreact = { "prettier" }, css = { "prettier" }, html = { "prettier" }, json = { "prettier" }, yaml = { "prettier" }, markdown = { "prettier" }, graphql = { "prettier" }, -- Lua lua = { "stylua" }, -- Python python = { "isort", "black" }, -- Go go = { "gofmt", "goimports" }, -- Rust rust = { "rustfmt" }, -- Shell sh = { "shfmt" }, bash = { "shfmt" }, zsh = { "shfmt" }, -- TOML toml = { "taplo" }, -- Use the "*" filetype to run formatters on all filetypes ["*"] = { "trim_whitespace" }, }, -- Set default options default_format_opts = { lsp_format = "fallback", }, -- Set up format-on-save -- format_on_save = { -- -- These options will be passed to conform.format() -- timeout_ms = 500, -- lsp_format = "fallback", -- }, -- Customize formatters formatters = { shfmt = { prepend_args = { "-i", "2" }, -- 2 spaces indentation }, }, }) -- Keybindings vim.keymap.set({ "n", "v" }, "lf", function() conform.format({ lsp_format = "fallback", async = false, timeout_ms = 500, }) end, { desc = "Format file or range (in visual mode)" }) end, }