Skip to main content

Plugin

Trait Plugin 

Source
pub trait Plugin:
    Any
    + Send
    + Sync {
Show 28 methods // Required methods fn name(&self) -> &'static str; fn version(&self) -> &'static str; fn capabilities(&self) -> PluginCapabilities; fn init(&mut self, ctx: &PluginContext) -> PluginResult<()>; fn as_any(&self) -> &dyn Any; fn as_any_mut(&mut self) -> &mut dyn Any; // Provided methods fn description(&self) -> &'static str { ... } fn min_editor_version(&self) -> Option<&'static str> { ... } fn dependencies(&self) -> &[&'static str] { ... } fn activate(&mut self, _ctx: &PluginContext) -> PluginResult<()> { ... } fn deactivate(&mut self, _ctx: &PluginContext) -> PluginResult<()> { ... } fn commands(&self) -> Vec<CommandConfig> { ... } fn pane_types(&self) -> Vec<PaneConfig> { ... } fn keybindings(&self) -> Vec<KeybindingConfig> { ... } fn themes(&self) -> Vec<ThemeDefinition> { ... } fn custom_table_panes(&self) -> Vec<CustomTableConfig> { ... } fn custom_chart_panes(&self) -> Vec<CustomChartConfig> { ... } fn custom_stat_panes(&self) -> Vec<StatPaneConfig> { ... } fn custom_gauge_panes(&self) -> Vec<GaugePaneConfig> { ... } fn lifecycle_hooks(&self) -> Option<Box<dyn LifecycleHook>> { ... } fn command_hooks(&self) -> Option<Box<dyn CommandHook>> { ... } fn keyboard_hooks(&self) -> Option<Box<dyn KeyboardHook>> { ... } fn theme_hooks(&self) -> Option<Box<dyn ThemeHook>> { ... } fn pane_hooks(&self) -> Option<Box<dyn PaneHook>> { ... } fn execute_command( &mut self, _command: &str, _args: &str, _ctx: &PluginContext, ) -> bool { ... } fn on_theme_changed(&mut self, _theme: Theme) { ... } fn refreshable_pane_types(&self) -> Vec<(&str, u32)> { ... } fn trigger_pane_refresh( &mut self, _pane_type: &str, _ctx: &PluginContext, ) -> bool { ... }
}
Expand description

The core plugin trait that all plugins must implement.

This trait defines the interface for plugin lifecycle management, capability declaration, and hook registration.

Required Methods§

Source

fn name(&self) -> &'static str

Returns the unique name of the plugin.

This name is used for identification and should be kebab-case (e.g., “git-blame”, “custom-charts”).

Source

fn version(&self) -> &'static str

Returns the version of the plugin (semver format).

Source

fn capabilities(&self) -> PluginCapabilities

Returns the capabilities this plugin provides.

Source

fn init(&mut self, ctx: &PluginContext) -> PluginResult<()>

Initialize the plugin with the given context.

This is called once when the plugin is first loaded. Return an error to prevent the plugin from loading.

Source

fn as_any(&self) -> &dyn Any

Get a reference to self as Any (for downcasting).

Source

fn as_any_mut(&mut self) -> &mut dyn Any

Get a mutable reference to self as Any (for downcasting).

Provided Methods§

Source

fn description(&self) -> &'static str

Returns a human-readable description of the plugin.

Source

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

Returns the minimum editor version required.

Source

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

Returns names of plugins this plugin depends on.

Source

fn activate(&mut self, _ctx: &PluginContext) -> PluginResult<()>

Activate the plugin.

This is called when the plugin is enabled (either at startup if enabled by default, or when the user enables it).

Source

fn deactivate(&mut self, _ctx: &PluginContext) -> PluginResult<()>

Deactivate the plugin.

This is called when the plugin is disabled. Plugins should clean up any resources and remove any UI elements.

Source

fn commands(&self) -> Vec<CommandConfig>

Returns the commands this plugin provides.

Source

fn pane_types(&self) -> Vec<PaneConfig>

Returns the pane types this plugin provides.

Source

fn keybindings(&self) -> Vec<KeybindingConfig>

Returns the keybindings this plugin provides.

Source

fn themes(&self) -> Vec<ThemeDefinition>

Returns the custom themes this plugin provides.

Only called if the plugin declares CUSTOM_THEMES capability.

Source

fn custom_table_panes(&self) -> Vec<CustomTableConfig>

Returns the custom table pane types this plugin provides.

Only called if the plugin declares PANES capability.

Source

fn custom_chart_panes(&self) -> Vec<CustomChartConfig>

Returns the custom chart pane types this plugin provides.

Only called if the plugin declares PANES capability.

Source

fn custom_stat_panes(&self) -> Vec<StatPaneConfig>

Returns the custom stat pane types this plugin provides.

Only called if the plugin declares PANES capability.

Source

fn custom_gauge_panes(&self) -> Vec<GaugePaneConfig>

Returns the custom gauge pane types this plugin provides.

Only called if the plugin declares PANES capability.

Source

fn lifecycle_hooks(&self) -> Option<Box<dyn LifecycleHook>>

Returns the lifecycle hooks this plugin wants to receive.

Source

fn command_hooks(&self) -> Option<Box<dyn CommandHook>>

Returns the command hooks this plugin wants to receive.

Source

fn keyboard_hooks(&self) -> Option<Box<dyn KeyboardHook>>

Returns the keyboard hooks this plugin wants to receive.

Source

fn theme_hooks(&self) -> Option<Box<dyn ThemeHook>>

Returns the theme hooks this plugin wants to receive.

Source

fn pane_hooks(&self) -> Option<Box<dyn PaneHook>>

Returns the pane hooks this plugin wants to receive.

Source

fn execute_command( &mut self, _command: &str, _args: &str, _ctx: &PluginContext, ) -> bool

Execute a command provided by this plugin.

Only called if the plugin declares COMMANDS capability.

Source

fn on_theme_changed(&mut self, _theme: Theme)

Called when the theme changes.

Only called if the plugin declares THEMING capability.

Source

fn refreshable_pane_types(&self) -> Vec<(&str, u32)>

Get pane types that have auto-refresh enabled.

Returns a list of (pane_type_name, refresh_interval_secs) pairs. Only called if the plugin declares PANES capability.

Source

fn trigger_pane_refresh( &mut self, _pane_type: &str, _ctx: &PluginContext, ) -> bool

Trigger a refresh for a specific pane type.

This is called by the editor when a pane needs to be refreshed (based on its refresh_interval). The plugin should fetch new data and call the appropriate set_*_data function.

Returns true if the refresh was triggered successfully.

Implementors§