mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-21 23:01:05 +00:00
25 lines
576 B
Rust
25 lines
576 B
Rust
use anyhow::Result;
|
|
use yazi_binding::runtime_scope;
|
|
use yazi_dds::Sendable;
|
|
use yazi_macro::succ;
|
|
use yazi_parser::app::LuaForm;
|
|
use yazi_plugin::LUA;
|
|
use yazi_shared::data::Data;
|
|
|
|
use crate::{Actor, Ctx, lives::Lives};
|
|
|
|
pub struct Lua;
|
|
|
|
impl Actor for Lua {
|
|
type Form = LuaForm;
|
|
|
|
const NAME: &str = "lua";
|
|
|
|
fn act(cx: &mut Ctx, opt: Self::Form) -> Result<Data> {
|
|
let chunk = LUA.load(&*opt.code).set_name("anonymous");
|
|
let result = Lives::scope(cx.core, || {
|
|
runtime_scope!(LUA, "inline", Sendable::value_to_data(&LUA, chunk.eval()?))
|
|
});
|
|
succ!(result?);
|
|
}
|
|
}
|