Skip to main content

Module format_chain

Module format_chain 

Source
Expand description

Who formats a range — an ordered chain of typed providers.

Three intents (indent, reflow, reformat) each resolve a ProviderChain; the first provider that is available and returns a result wins. See docs/dev/architecture/text-reflow.md §6.

This module is the vocabulary only — parsing, formatting and the ordering. Resolution lives in the host (RF.5), because it needs the LSP client, the process runner and the buffer.

§Why not formatprg / equalprg

Those are one string slot each with a precedence order hardcoded in Rust. Every new placement — “prettier for markdown but the server for TypeScript”, or a WASM plugin supplying a formatter — is then a host patch. The whole field converged on typed ordered lists instead (conform.nvim’s formatters_by_ft + lsp_format, Zed’s formatter: union, Helix’s [language.formatter]), and paramount #2 is the reason to follow: a chain that is data can be extended by a plugin, and an if in do_format_request cannot.

Structs§

ProviderChain
An ordered list of providers for one intent.

Enums§

FormatIntent
Which of the three formatting jobs a range wants done.
FormatProvider
One rung of a ProviderChain.