return { 'stevearc/conform.nvim', event = { 'BufWritePre' }, cmd = { 'ConformInfo' }, keys = { { -- Customize or remove this keymap to your liking 'f', function() require('conform').format({ async = true }) end, mode = '', desc = 'Format buffer', }, }, -- This will provide type hinting with LuaLS ---@module "conform" ---@type conform.setupOpts opts = { -- Define your formatters formatters_by_ft = { lua = { 'stylua' }, javascript = { 'prettierd', 'prettier', stop_after_first = true }, javascriptreact = { 'prettierd', 'prettier', stop_after_first = true }, typescript = { 'prettierd', 'prettier', stop_after_first = true }, typescriptreact = { 'prettierd', 'prettier', stop_after_first = true }, css = { 'prettierd', 'prettier', stop_after_first = true }, scss = { 'prettierd', 'prettier', stop_after_first = true }, json = { 'prettierd', 'prettier', stop_after_first = true }, jsonc = { 'prettierd', 'prettier', stop_after_first = true }, markdown = { 'prettierd', 'prettier', stop_after_first = true }, cs = { 'csharpierd' }, php = { 'php_cs_fixer' }, go = { 'gofmt' }, }, -- Set default options default_format_opts = { lsp_format = 'fallback', }, -- Set up format-on-save format_on_save = { timeout_ms = 3000 }, -- Customize formatters formatters = { shfmt = { prepend_args = { '-i', '2' }, }, astyle = { prepend_args = { '--style=java', '--max-code-length=80', '--squeeze-ws' }, }, csharpierd = { command = 'csharpierd', args = { '$RELATIVE_FILEPATH' }, stdin = true, }, }, }, init = function() -- If you want the formatexpr, here is the place to set it vim.o.formatexpr = "v:lua.require'conform'.formatexpr()" end, }