mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-23 15:51:03 +00:00
24 lines
566 B
Rust
24 lines
566 B
Rust
use anyhow::Result;
|
|
use yazi_binding::{Sendable, runtime_scope};
|
|
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, 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?);
|
|
}
|
|
}
|