Expand description
Enya Plugin System
This crate provides a neovim-style plugin system for extending editor functionality.
It is designed to be decoupled from any specific editor implementation through
the PluginHost trait.
§Overview
The plugin system supports three types of plugins:
- Config plugins (
.toml) - Simple plugins defined in TOML - Lua plugins (
.lua) - Dynamic plugins using Lua scripting - Native plugins - Rust plugins implementing the
Plugintrait
§Architecture
┌─────────────────────────────────────────────────────────┐
│ Host Application │
│ (implements PluginHost trait) │
└─────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────┐
│ PluginContext │
│ (provides host services to plugins) │
└─────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────┐
│ PluginRegistry │
│ (manages plugin lifecycle) │
└─────────────────────────────────────────────────────────┘
│
┌────────────────┼────────────────┐
▼ ▼ ▼
┌──────────┐ ┌──────────┐ ┌──────────┐
│ Config │ │ Lua │ │ Native │
│ Plugin │ │ Plugin │ │ Plugin │
└──────────┘ └──────────┘ └──────────┘§Example: Implementing PluginHost
ⓘ
use enya_plugin::{
PluginHost, PluginContext, PluginRegistry, NotificationLevel, LogLevel, Theme, BoxFuture,
};
use std::sync::Arc;
struct MyEditor {
// ... editor state
}
impl PluginHost for MyEditor {
fn notify(&self, level: NotificationLevel, message: &str) {
// Show notification to user
}
fn request_repaint(&self) {
// Request UI refresh
}
fn log(&self, level: LogLevel, message: &str) {
// Log message
}
fn version(&self) -> &'static str {
"1.0.0"
}
fn is_wasm(&self) -> bool {
false
}
fn theme(&self) -> Theme {
Theme::Dark
}
fn spawn(&self, future: BoxFuture<()>) {
// Spawn async task
}
}
fn setup_plugins(editor: Arc<MyEditor>) {
let ctx = PluginContext::new(editor);
let mut registry = PluginRegistry::new();
registry.init(ctx);
// Register and activate plugins...
}Re-exports§
pub use lua::EXAMPLE_LUA_PLUGIN;pub use lua::LuaPlugin;
Modules§
- lua
- Lua plugin support using mlua.
Structs§
- Chart
Data Point - A single data point in a chart series.
- Chart
Series - A single series in a chart (line).
- Command
Config - Configuration for a custom command provided by a plugin.
- Config
Command - A command defined in a config plugin.
- Config
Keybinding - A keybinding defined in a config plugin.
- Config
Plugin - A plugin loaded from a config file.
- Custom
Chart Config - Configuration for a custom chart pane type.
- Custom
Chart Data - Data to display in a custom chart pane.
- Custom
Table Config - Configuration for a custom table pane type.
- Custom
Table Data - Data returned by a custom table pane’s fetch function.
- Custom
Table Row - A single row of data for a custom table.
- Focused
Pane Info - Information about the currently focused pane. Used for sharing context to external services like Slack/Discord.
- Gauge
Pane Config - Configuration for a custom gauge pane type.
- Gauge
Pane Data - Data to display in a gauge pane.
- Headless
Plugin Host - A headless implementation of
PluginHostfor CLI use. - Http
Error - HTTP request error.
- Http
Response - HTTP response returned from http_get/http_post.
- KeyCombo
- Represents a key combination.
- KeyEvent
- Represents a keyboard event.
- Keybinding
Config - Configuration for a keyboard shortcut provided by a plugin.
- Pane
Config - Configuration for a custom pane type provided by a plugin.
- Plugin
Capabilities - Capabilities that a plugin can provide.
- Plugin
Context - Context provided to plugins for interacting with the host.
- Plugin
Id - Unique identifier for a registered plugin.
- Plugin
Info - Information about a registered plugin.
- Plugin
Loader - Plugin loader that discovers and loads plugins from the filesystem.
- Plugin
Manifest - Metadata for a loadable plugin.
- Plugin
Meta - Plugin metadata from manifest.
- Plugin
Registry - Central registry for managing plugins.
- Stat
Pane Config - Configuration for a custom stat pane type.
- Stat
Pane Data - Data to display in a stat pane.
- Table
Column Config - Column configuration for a custom table pane.
- Theme
Colors - Color palette for a custom theme.
- Theme
Customization - Theme customization provided by a plugin.
- Theme
Definition - A custom theme definition from a plugin.
- Threshold
Config - Threshold configuration for stat/gauge visualizations.
Enums§
- Command
Hook Result - Result of a command hook execution.
- Keyboard
Hook Result - Result of a keyboard hook execution.
- LogLevel
- Log level for plugin logging.
- Notification
Level - Notification level for user-facing messages.
- Plugin
Error - Errors that can occur during plugin operations.
- Plugin
State - Runtime state of a plugin.
- Theme
- Application theme.
- Theme
Base - Base theme to inherit missing colors from.
Constants§
- EXAMPLE_
PLUGIN - Example plugin template.
Traits§
- Command
Hook - Hook for intercepting command execution.
- Keyboard
Hook - Hook for intercepting keyboard events.
- Lifecycle
Hook - Hook for intercepting lifecycle events.
- Pane
Hook - Hook for pane-related events.
- Plugin
- The core plugin trait that all plugins must implement.
- Plugin
Host - Trait for the host application to implement.
- Theme
Hook - Hook for theme-related events.
Type Aliases§
- BoxFuture
- A boxed future for async operations.
- Plugin
Context Ref - Reference-counted plugin context.
- Plugin
Host Ref - Reference-counted plugin host.
- Plugin
Result - Result type for plugin operations.