pub enum FormatProvider {
Native,
Lsp,
LangDefault,
External(String),
Plugin(String),
}Expand description
One rung of a ProviderChain.
The set is open at the edges (External, Plugin) and closed in the
middle, which is what lets parse reject a typo like nativ while
still admitting formatters the editor has never heard of.
Variants§
Native
The built-in engine for the intent: the tree-sitter indent engine
for indent, the textwidth reflow engine for reflow. Not
meaningful for reformat, where it resolves to nothing and the
chain moves on.
Lsp
textDocument/formatting or rangeFormatting from an attached
server.
Eligible in any chain, default only in reformat. The
protocol has no indent-only and no reflow request, so putting
this in indent or reflow gets you a reformat — which is a
legitimate thing to want and a bad default, because in the common
case (rustfmt’s wrap_comments is off by default, prettier’s
proseWrap defaults to preserve) it silently does nothing to a
comment paragraph. text-reflow.md §5.
LangDefault
The built-in per-language formatter table
(lattice_format::FormatterSpec::for_lang) — rustfmt, prettier,
black, gofmt and peers, each probed on PATH and skipped when
absent.
External(String)
A user-named external filter, as a command line:
external:prettier --stdin-filepath %. The replacement for
formatprg, and for the equalprg that was never implemented.
Plugin(String)
A formatter contributed by a WASM plugin, by id.
Implementations§
Source§impl FormatProvider
impl FormatProvider
Sourcepub fn label(&self) -> String
pub fn label(&self) -> String
Canonical string form. Round-trips with Self::parse.
Sourcepub fn parse(s: &str) -> Result<Self, String>
pub fn parse(s: &str) -> Result<Self, String>
Parse one rung.
The prefixed forms carry a payload; the bare forms are a closed
set, so an unrecognised bare word is an error rather than being
silently taken for an external command. That distinction is the
point of the external: prefix existing at all — without it,
:set format.reformat=nativ would install a chain that tries to
run a program called nativ.
Trait Implementations§
Source§impl Clone for FormatProvider
impl Clone for FormatProvider
Source§fn clone(&self) -> FormatProvider
fn clone(&self) -> FormatProvider
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for FormatProvider
impl Debug for FormatProvider
Source§impl Display for FormatProvider
impl Display for FormatProvider
impl Eq for FormatProvider
Source§impl PartialEq for FormatProvider
impl PartialEq for FormatProvider
impl StructuralPartialEq for FormatProvider
Auto Trait Implementations§
impl Freeze for FormatProvider
impl RefUnwindSafe for FormatProvider
impl Send for FormatProvider
impl Sync for FormatProvider
impl Unpin for FormatProvider
impl UnsafeUnpin for FormatProvider
impl UnwindSafe for FormatProvider
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.