pub const EXAMPLE_LUA_PLUGIN: &str = r#"-- Example Enya Lua Plugin
-- Place this file in ~/.enya/plugins/
-- Plugin metadata (required)
plugin = {
name = "example-lua",
version = "0.1.0",
description = "An example Lua plugin showing available features"
}
-- Register a simple command
enya.register_command("lua-hello", {
description = "Say hello from Lua",
aliases = {"lhello"},
accepts_args = true
}, function(args)
if args == "" then
enya.notify("info", "Hello from Lua!")
else
enya.notify("info", "Hello, " .. args .. "!")
end
return true
end)
-- Register a command with conditional logic
enya.register_command("lua-check", {
description = "Check something with conditional logic",
accepts_args = true
}, function(args)
local num = tonumber(args)
if num == nil then
enya.notify("error", "Please provide a number")
return false
end
if num > 100 then
enya.notify("warn", "That's a large number: " .. tostring(num))
elseif num < 0 then
enya.notify("error", "Negative numbers not allowed")
return false
else
enya.notify("info", "Number " .. tostring(num) .. " is valid")
end
return true
end)
-- Register keybindings
enya.keymap("Space+l+h", "lua-hello", "Lua hello")
enya.keymap("Space+l+c", "lua-check", "Lua check")
-- Lifecycle hooks (optional)
function on_activate()
enya.log("info", "Example Lua plugin activated!")
end
function on_deactivate()
enya.log("info", "Example Lua plugin deactivated!")
end
"#;Expand description
Example Lua plugin template.