pub struct Subscriptions(HashMap<SubscriptionKey, Vec<Subscription>>);
Expand description

A map of all registered subscriptions.

Tuple Fields

0: HashMap<SubscriptionKey, Vec<Subscription>>

Implementations

Subscribe to a Neovim autocmd event.

Subscriptions are not active immediately but only after set_autocmds is called. At the moment, all calls to subscribe must be made before calling set_autocmds.

This function is wrapped by shell::State.

Arguments:
  • key: The subscription key to register. See :help autocmd-events for a list of supported event names. Event names can be comma-separated.

  • args: A list of expressions to be evaluated when the event triggers. Expressions are evaluated using Vimscript. The results are passed to the callback as a list of Strings. This is especially useful as Neovim::eval is synchronous and might block if called from the callback function; so always use the args mechanism instead.

  • cb: The callback function. This will be called each time the event triggers or when run_now is called. It is passed a vector with the results of the evaluated expressions given with args.

Example

Call a function each time a buffer is entered or the current working directory is changed. Pass the current buffer name and directory to the callback.

let my_subscription = shell.state.borrow()
    .subscribe("BufEnter,DirChanged", &["expand(@%)", "getcwd()"], move |args| {
        let filename = &args[0];
        let dir = &args[1];
        // do stuff
    });

Register all subscriptions with Neovim.

This function is wrapped by shell::State.

Trigger given event.

Wrapper around on_notify for easy calling with a neovim_lib::Handler implementation.

This function is wrapped by shell::State.

Manually trigger the given subscription.

The nvim instance is needed to evaluate the args expressions.

This function is wrapped by shell::State.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.