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§
Sourcefn name(&self) -> &'static str
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”).
Sourcefn capabilities(&self) -> PluginCapabilities
fn capabilities(&self) -> PluginCapabilities
Returns the capabilities this plugin provides.
Sourcefn init(&mut self, ctx: &PluginContext) -> PluginResult<()>
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.
Sourcefn as_any_mut(&mut self) -> &mut dyn Any
fn as_any_mut(&mut self) -> &mut dyn Any
Get a mutable reference to self as Any (for downcasting).
Provided Methods§
Sourcefn description(&self) -> &'static str
fn description(&self) -> &'static str
Returns a human-readable description of the plugin.
Sourcefn min_editor_version(&self) -> Option<&'static str>
fn min_editor_version(&self) -> Option<&'static str>
Returns the minimum editor version required.
Sourcefn dependencies(&self) -> &[&'static str]
fn dependencies(&self) -> &[&'static str]
Returns names of plugins this plugin depends on.
Sourcefn activate(&mut self, _ctx: &PluginContext) -> PluginResult<()>
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).
Sourcefn deactivate(&mut self, _ctx: &PluginContext) -> PluginResult<()>
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.
Sourcefn commands(&self) -> Vec<CommandConfig>
fn commands(&self) -> Vec<CommandConfig>
Returns the commands this plugin provides.
Sourcefn pane_types(&self) -> Vec<PaneConfig>
fn pane_types(&self) -> Vec<PaneConfig>
Returns the pane types this plugin provides.
Sourcefn keybindings(&self) -> Vec<KeybindingConfig>
fn keybindings(&self) -> Vec<KeybindingConfig>
Returns the keybindings this plugin provides.
Sourcefn themes(&self) -> Vec<ThemeDefinition>
fn themes(&self) -> Vec<ThemeDefinition>
Returns the custom themes this plugin provides.
Only called if the plugin declares CUSTOM_THEMES capability.
Sourcefn custom_table_panes(&self) -> Vec<CustomTableConfig>
fn custom_table_panes(&self) -> Vec<CustomTableConfig>
Returns the custom table pane types this plugin provides.
Only called if the plugin declares PANES capability.
Sourcefn custom_chart_panes(&self) -> Vec<CustomChartConfig>
fn custom_chart_panes(&self) -> Vec<CustomChartConfig>
Returns the custom chart pane types this plugin provides.
Only called if the plugin declares PANES capability.
Sourcefn custom_stat_panes(&self) -> Vec<StatPaneConfig>
fn custom_stat_panes(&self) -> Vec<StatPaneConfig>
Returns the custom stat pane types this plugin provides.
Only called if the plugin declares PANES capability.
Sourcefn custom_gauge_panes(&self) -> Vec<GaugePaneConfig>
fn custom_gauge_panes(&self) -> Vec<GaugePaneConfig>
Returns the custom gauge pane types this plugin provides.
Only called if the plugin declares PANES capability.
Sourcefn lifecycle_hooks(&self) -> Option<Box<dyn LifecycleHook>>
fn lifecycle_hooks(&self) -> Option<Box<dyn LifecycleHook>>
Returns the lifecycle hooks this plugin wants to receive.
Sourcefn command_hooks(&self) -> Option<Box<dyn CommandHook>>
fn command_hooks(&self) -> Option<Box<dyn CommandHook>>
Returns the command hooks this plugin wants to receive.
Sourcefn keyboard_hooks(&self) -> Option<Box<dyn KeyboardHook>>
fn keyboard_hooks(&self) -> Option<Box<dyn KeyboardHook>>
Returns the keyboard hooks this plugin wants to receive.
Sourcefn theme_hooks(&self) -> Option<Box<dyn ThemeHook>>
fn theme_hooks(&self) -> Option<Box<dyn ThemeHook>>
Returns the theme hooks this plugin wants to receive.
Sourcefn pane_hooks(&self) -> Option<Box<dyn PaneHook>>
fn pane_hooks(&self) -> Option<Box<dyn PaneHook>>
Returns the pane hooks this plugin wants to receive.
Sourcefn execute_command(
&mut self,
_command: &str,
_args: &str,
_ctx: &PluginContext,
) -> bool
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.
Sourcefn on_theme_changed(&mut self, _theme: Theme)
fn on_theme_changed(&mut self, _theme: Theme)
Called when the theme changes.
Only called if the plugin declares THEMING capability.
Sourcefn refreshable_pane_types(&self) -> Vec<(&str, u32)>
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.
Sourcefn trigger_pane_refresh(
&mut self,
_pane_type: &str,
_ctx: &PluginContext,
) -> bool
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.