conform.nvim runs external formatters inside Neovim while preserving marks and folds. It applies minimal text edits, supports range formatting, and can wrap lazy LSP formatters.
Overview
conform.nvim is a Neovim plugin that formats buffers by shelling out to configured CLI formatters per filetype. It calculates minimal diffs instead of replacing entire buffers, which keeps extmarks, folds, and cursor position stable.
The plugin can intercept LSP format responses that would otherwise rewrite whole files and convert them into piecewise edits. Range formatting works even when a formatter lacks native range support because conform still diff-limits changes.
Setup involves declaring formatters_by_ft and optional format-on-save hooks similar to vim.lsp.buf.format. Built-in formatter metadata covers many languages, with overrides for custom arguments or entirely user-defined commands.
Injected-language formatting lets conform run inside Markdown code fences or other treesitter-injected regions, and :ConformInfo helps debug formatter availability.
Key features
- Minimal-diff buffer formatting
- Format-on-save hooks
- Range formatting support
- LSP formatter wrapping
- Injected language formatting
- Large built-in formatter catalog
Use cases
- Consistent Neovim formatting
- Fixing heavy-handed LSP formatters
- Formatting code blocks in Markdown
- Running multiple formatters in sequence