macro_rules! declare_plugin {
(
name: $name:literal,
version: $version:literal,
$(builtins: { $($cmd:literal => $handler:path),+ $(,)? } $(,)?)?
$(completions: { $($ccmd:literal => $cgen:path),+ $(,)? } $(,)?)?
$(compfns: { $($cfname:literal => $cfhandler:path),+ $(,)? } $(,)?)?
) => { ... };
}Expand description
Declare a plugin: its identity, the builtins it registers, and the
native completions it provides. Expands to the #[no_mangle] extern "C" fn znative_init the host looks for, plus the 'static
PluginInfo.
builtins:— each"name" => handlerregisters a command. A handler isfn(&Host, &Args) -> c_int.completions:— each"cmd" => generatorwires a native completion into zsh’s completion system (compsys) for commandcmd. A generator is alsofn(&Host, &Args) -> c_int; it receives$CURRENT(1-based index of the word being completed) followed by every word on the line, and emits candidates withHost::add_match. (Requirescompdef— load the plugin aftercompinit.)
Both sections are optional.
ⓘ
declare_plugin! {
name: "greet",
version: "0.1.0",
builtins: { "greet" => greet },
completions: { "greet" => greet_complete },
}