pub struct HookBuilder<H: Hookable> { /* private fields */ }Expand description
A struct used in order to specify more options for hooks.
You can set three options currently:
HookBuilder::grouped: Groups this hook with others, allowing them to all be removed at once.HookBuilder::filter: Filters when this hook should be called, by giving a struct for whichHimplementsPartialEq. An example is theFocusedOnhook, which acceptsHandles andHandlepairs.
Implementations§
Source§impl<H: Hookable> HookBuilder<H>
impl<H: Hookable> HookBuilder<H>
Sourcepub fn grouped(self, ns: Ns) -> Self
pub fn grouped(self, ns: Ns) -> Self
Groups this hook with a namespace.
By adding a namespace to this group, you are then able to
remove a group of hooks by calling hook::remove.
Sourcepub fn lateness(self, lateness: usize) -> Self
pub fn lateness(self, lateness: usize) -> Self
Set the “lateness” of this hook.
The lateness determines how “late” a hook should be
applied. For example, if a hook has a lateness of 0 and
another has a lateness of usize::MAX, the latter one
will be triggered after the first one.
An example of where this is useful is with hooks that need
to know which lines were printed. For example, if I print
the line numbers, and then in a later hook in the same
BufferUpdated trigger, an edit is made, the printed
line numbers may now be wrong.
The general wisdom is that, in order to not break things,
if your hook relies on meta Tags (Inlay, Conceal
or Spacer) or edits the Text of the Buffer,
you should make use of a lower lateness.
If it only makes use of “light” Tags (like FormTag)
or relies on no future changes on the same BufferUpdated
trigger (by e.g. getting the printed lines), then it
should have a higher lateness.
By default, every hook has a lateness of 100.