return { 'conform.nvim', event = { 'BufWritePre' }, cmd = { 'ConformInfo' }, keys = { { 'cf', function() require('conform').format() end, desc = 'format', }, { 'cF', function() require('conform').format({ formatters = { 'injected' }, timeout_ms = 3000, }) end, mode = { 'n', 'v' }, desc = 'format injected langs', }, }, after = function() require('conform').setup({ format_on_save = function(buf) if (vim.g.autoformat == false) or (vim.b[buf].autoformat == false) then return end return { timeout_ms = 3000, lsp_format = 'fallback' } end, -- Prettier is last but only activated if there is a config available, -- thereby giving it priority only when it is wanted. formatters_by_ft = { css = { 'biome', 'prettier' }, fish = { 'fish_indent' }, graphql = { 'biome', 'prettier' }, handlebars = { 'prettier' }, html = { 'prettier' }, javascript = { 'biome', 'prettier' }, javascriptreact = { 'biome', 'prettier' }, json = { 'biome', 'prettier' }, jsonc = { 'biome', 'prettier' }, lua = { 'stylua' }, less = { 'prettier' }, markdown = { 'prettier' }, ['markdown.mdx'] = { 'prettier' }, scss = { 'prettier' }, sh = { 'shfmt' }, typescript = { 'biome', 'prettier' }, typescriptreact = { 'biome', 'prettier' }, vue = { 'biome', 'prettier' }, yaml = { 'prettier' }, }, formatters = { biome = { require_cwd = true, }, prettier = { condition = function(_, ctx) return MarleyVim.prettier.has_parser(ctx) and MarleyVim.prettier.has_config(ctx) end, }, }, }) vim.o.formatexpr = "v:lua.require'conform'.formatexpr()" end, }