Expand description
Lua plugin support using mlua.
This module enables writing plugins in Lua for dynamic behavior beyond what TOML config plugins allow. Lua plugins can have conditional logic, access editor state, and create complex workflows.
§Example Lua Plugin
-- ~/.enya/plugins/my-plugin.lua
-- Plugin metadata (required)
plugin = {
name = "my-lua-plugin",
version = "0.1.0",
description = "A Lua plugin example"
}
-- Register a command
enya.register_command("greet", {
description = "Greet the user",
aliases = {"hello", "hi"},
accepts_args = true
}, function(args)
if args == "" then
enya.notify("info", "Hello, World!")
else
enya.notify("info", "Hello, " .. args .. "!")
end
return true
end)
-- Register a keybinding
enya.keymap("Space+x+g", "greet", "Greet user")
-- Lifecycle hooks (optional)
function on_activate()
enya.log("info", "Plugin activated!")
end
function on_deactivate()
enya.log("info", "Plugin deactivated!")
end§Available API
§Registration Functions (available during load)
enya.register_command(name, config, callback)- Register a commandenya.keymap(keys, command, description, [modes])- Register a keybinding
§Runtime Functions (available in callbacks)
enya.notify(level, message)- Show notification (“info”, “warn”, “error”)enya.log(level, message)- Log a messageenya.request_repaint()- Request UI refreshenya.editor_version()- Get editor version stringenya.is_wasm()- Check if running in WASMenya.theme_name()- Get current theme nameenya.clipboard_write(text)- Write text to clipboardenya.clipboard_read()- Read text from clipboard (returns nil if empty)enya.execute(command, [args])- Execute another commandenya.http_get(url, [headers])- HTTP GET, returns{status, body, headers}or{error}enya.http_post(url, body, [headers])- HTTP POST, returns{status, body, headers}or{error}enya.get_focused_pane()- Get focused pane info{pane_type, title, query, metric_name}or nil
Structs§
- LuaPlugin
- A Lua-based plugin.
Constants§
- EXAMPLE_
LUA_ PLUGIN - Example Lua plugin template.