Skip to main content

DiffMode

Struct DiffMode 

Source
pub struct DiffMode;
Expand description

diff-mode minor. Empty marker in v1 (D.5.a): the bit other layers consult. D.5.b/c land the do/dp chord bindings against the MinorMode(ModeId::new("diff-mode")) keymap layer (K.1.b shape).

Implementations§

Trait Implementations§

Source§

impl Mode for DiffMode

Source§

fn keymap(&self) -> Keymap

MO.x (2026-06-24): contribute the do/dp chords through the standard Mode::keymap() seam (the multibuffer ]e/[e pattern). The host’s K.2.4 translation pass resolves each entry’s cmd name against the CommandRegistry and pushes the layer under MinorMode(diff-mode), gated to diff-active buffers by K.1.c — retiring the host’s bespoke explicit push_layer (the emacs-keys host-push that DX.5/DX.7 left as this follow-up). The binding choice now lives wholly with the mode; the host pushes nothing diff-specific.

Source§

fn action_handlers(&self) -> Vec<ActionHandlerContribution>

CR.1 (2026-06-24): the do/dp chord handler bodies, now mode-owned (they were Editor::do_diff_get/do_diff_put + Action::DiffGet/DiffPut host-side). Bound globally (buffer-agnostic) at boot by the host’s register_mode_action_handlers walk: diff-mode is active on many buffers at once and the ActionHandlerRegistry is keyed by CommandId alone, so a per-on_activate registration would let one buffer’s deactivation evict the handler for the others — the snippet action:snippet-expand precedent. Each handler reads the active buffer + cursor from the ActionContext and the diff session from the DiffSubsystemHandle service, resolves the hunk via DiffSubsystem::diff_*_effect, and hands the host an Effect::ApplyEdit (CR.0): the mode owns the resolution, the host owns the apply. do/dp pass None as the target (auto-resolve the peer in 2-way; “target required” in 3-way); the :diffget/:diffput optional <bufnr> is a separate host call into the same diff_*_effect resolver.

Source§

fn on_activate( &self, ctx: ModeContext, ) -> Pin<Box<dyn Future<Output = Result<DiffModeGuard, ModeActivationError>> + Send + '_>>

DX.3-C7 (2026-06-24) / D-fix.5 (2026-06-26): register the buffer’s diff fold sources.

Mirrors MultibufferMode::on_activate: pull the FoldOverlayService + the data handle (DiffSubsystemHandle) + the ConfigRegistry from the service registry, resolve the diff session and the buffer’s ranges slot, and register TWO sources over them:

  • HunkFoldSource — folds the hunks (open by default);
  • UnchangedFoldSource (D-fix.5) — folds their complement, the unchanged gaps (closed by default; vimdiff foldmethod=diff).

D-fix.5 resolves via lookup_session_for (not the primary-only lookup) + participant_slot, so EVERY participant — including the baseline-side secondary buffer — registers sources folding its OWN side. Both panes fold in lockstep; under scroll-bind, folding only one side would desync the side-by-side view.

The returned DiffModeGuard’s Drop removes both sources when the mode deactivates. Missing service / no session / no slot just skips (empty guard) — folds inactive, never a panic.

Source§

type Guard = DiffModeGuard

Owned cleanup token returned by Self::on_activate. Read more
Source§

fn id(&self) -> ModeId

Canonical identity. Same value every call. Read more
Source§

fn kind(&self) -> ModeKind

Major or minor. Read at registration and on every activation call (activate_major on a minor, or vice versa, is ModeActivationError::WrongKind).
Source§

fn gutter_decorations(&self, ctx: &DecorationCtx<'_>) -> Vec<GutterDecoration>

Gutter sign decorations this mode contributes while active. Called once per pane per frame with a DecorationCtx carrying relevant render-state snapshots (diff sign map, LSP diagnostics arc). Returns per-line GutterDecoration values; the renderer partitions them by variant into the appropriate gutter column. Default: empty (no contribution).
Source§

fn target_buffer_kind(&self) -> Option<BufferKind>

For major modes, the BufferKind this mode is the default major for (H.2, 2026-05-31). ModeRegistry::register indexes this so ModeRegistry::find_major_for_kind can dispatch buffer-creation events to the right major without host-side match BufferKind { ... } blocks. Read more
Source§

fn target_language(&self) -> Option<&str>

For major modes, the language this mode is the default major for, by canonical name (Lang::name() — "rust", "org") (OM.1). The peer of target_buffer_kind for the dispatch path BufferKind::Document takes: language detection rather than kind dispatch. Read more
Source§

fn options(&self) -> OptionOverrideSet

Option overrides this mode contributes. Pure declarative (same return value every call); the host merges these into the buffer’s option-resolution layer stack while the mode is active, at the mode’s layer (later-activated minors win ties), and drops them on deactivation. Build with lattice_config::overrides! { lattice_config::Wrap = true, … }.
Source§

fn decorations(&self) -> Vec<DecorationProvider>

Decoration providers (gutter / inline / overlay / statusline). Stub — reserved for the WIT plugin path (M.10).
Source§

fn completion_sources(&self) -> Vec<CompletionSourceContribution>

Insert-mode completion sources this mode contributes while active on a buffer. Empty by default; minors that own a completion source (lsp-completion-mode, snippet-completion-mode, buffer-words-mode, tree-sitter-completion-mode, path-completion-mode, plugin sources) override.
Source§

fn required_capabilities(&self) -> CapabilitySet

Capabilities the mode requires. Validated at activation; missing capability ⇒ ModeActivationError::MissingCapability, never silent skip.
Source§

fn conflicts_with(&self) -> &[ModeId]

Modes this one cannot be active alongside. Read more
Source§

fn implies(&self) -> &[ModeId]

Minor modes activating this mode also activates. Used by relative-line-numbers-mode ⇒ line-numbers-mode, and by read-only majors ⇒ read-only-mode. Read more
Source§

fn presents_extensions(&self) -> &[&'static str]

File extensions (lowercase, no dot) this major PRESENTS rather than edits — the file is never loaded as text. Read more
Source§

fn mirrors_option(&self) -> Option<&'static str>

Declarative mirror hint for “this mode is the on/off switch for a typed option of the same observable state”. Some(canonical_name) ⇒ a host-driven cascade keeps the mode’s active state and the option’s value in sync.
Source§

fn invocation_runner(&self) -> Option<ModeId>

Invocation-runner discovery (2026-05-26). Modes that own command-invocation dispatch for their buffer kind (terminal-mode, oil-mode, file-tree-mode, help-mode, …) return their canonical ModeId; the host registers a runner function under that id at boot, and Editor::run_invocation looks it up by walking the active modes on the active pane’s buffer (minors first, then major) before falling back to the central grammar Action gate. Read more
Source§

fn refresh_action(&self) -> Option<&'static str>

Which of this mode’s own actions refreshes its view, or None (the default) when the mode backs nothing refreshable (RV.1, 2026-08-10). Read more
Source§

fn fold_toggle_action(&self) -> Option<&'static str>

Which of this mode’s actions <Tab> fires, and the declaration that pulls in foldable-view-mode — the shared minor owning the chord. Read more
Source§

fn refresh_on_open(&self) -> bool

Should re-opening this view re-run its refresh? Read more
Source§

fn activation_policy(&self) -> ActivationPolicy

A minor mode’s default auto-activation policy (MA.1; mode-architecture.md §7.4). The host’s minor-activation resolver reads this for every registered minor when a buffer enters a major mode, and activates those whose policy admits the entered major. The default is ActivationPolicy::Manual — auto-activate nowhere until the mode or the user opts in. Ignored for major modes (a buffer’s major is chosen by the major resolver, not this allowlist).
Source§

fn editable_tail(&self) -> Option<EditableTail>

The mode’s editable tail on an otherwise read-only buffer, or None (the default) for a fully read-only / fully writable buffer (AU‑3). Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync> ⓘ

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<M> DynMode for M
where M: Mode,

Source§

fn id(&self) -> ModeId

Forwards to Mode::id.
Source§

fn kind(&self) -> ModeKind

Forwards to Mode::kind.
Source§

fn target_buffer_kind(&self) -> Option<BufferKind>

Source§

fn target_language(&self) -> Option<&str>

Source§

fn options(&self) -> OptionOverrideSet

Forwards to Mode::options.
Source§

fn keymap(&self) -> Keymap

Forwards to Mode::keymap.
Source§

fn decorations(&self) -> Vec<DecorationProvider>

Forwards to Mode::decorations.
Source§

fn gutter_decorations(&self, ctx: &DecorationCtx<'_>) -> Vec<GutterDecoration>

Source§

fn completion_sources(&self) -> Vec<CompletionSourceContribution>

Source§

fn action_handlers(&self) -> Vec<ActionHandlerContribution>

Source§

fn required_capabilities(&self) -> CapabilitySet

Source§

fn conflicts_with(&self) -> &[ModeId]

Source§

fn implies(&self) -> &[ModeId]

Forwards to Mode::implies.
Source§

fn presents_extensions(&self) -> &[&'static str]

Source§

fn mirrors_option(&self) -> Option<&'static str>

Source§

fn invocation_runner(&self) -> Option<ModeId>

Source§

fn refresh_action(&self) -> Option<&'static str>

Source§

fn fold_toggle_action(&self) -> Option<&'static str>

Source§

fn refresh_on_open(&self) -> bool

Source§

fn activation_policy(&self) -> ActivationPolicy

Source§

fn editable_tail(&self) -> Option<EditableTail>

Forwards to Mode::editable_tail.
Source§

fn on_activate_dyn<'a>( &'a self, ctx: ModeContext, ) -> Pin<Box<dyn Future<Output = Result<Box<dyn Any + Send>, ModeActivationError>> + Send + 'a>>

Type-erased lifecycle entry. Returns a future whose output is the typed Guard erased to Box<dyn Any + Send>. The dispatcher stashes this box keyed by (BufferId, ModeId); deactivation drops it.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> IntoMaybeUndefined<T> for T

§

fn into_maybe_undefined(self) -> MaybeUndefined<T>

Converts this value into a three-state builder argument.
§

impl<T> IntoOption<T> for T

§

fn into_option(self) -> Option<T>

Converts this value into an optional builder argument.
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> Pointee for T

§

type Pointer = u32

§

fn debug( pointer: <T as Pointee>::Pointer, f: &mut Formatter<'_>, ) -> Result<(), Error>

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more