mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 00:31:04 +00:00
24 lines
567 B
Rust
24 lines
567 B
Rust
use anyhow::Result;
|
|
use yazi_binding::runtime_scope;
|
|
use yazi_macro::succ;
|
|
use yazi_parser::app::LuaForm;
|
|
use yazi_plugin::LUA;
|
|
use yazi_shared::data::{Data, Sendable};
|
|
|
|
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, form: Self::Form) -> Result<Data> {
|
|
let chunk = LUA.load(&*form.code).set_name("anonymous");
|
|
let result = Lives::scope(cx.core, |_| {
|
|
runtime_scope!(LUA, "inline", Sendable::value_to_data(&LUA, chunk.eval()?))
|
|
});
|
|
succ!(result?);
|
|
}
|
|
}
|