From a896b44f2961b865a020ef1fef94b395b0629608 Mon Sep 17 00:00:00 2001 From: sxyazi Date: Mon, 28 Oct 2024 13:31:03 +0800 Subject: [PATCH] .. --- yazi-plugin/src/bindings/bindings.rs | 4 +++- yazi-plugin/src/bindings/permit.rs | 2 +- yazi-plugin/src/bindings/position.rs | 4 ++-- yazi-plugin/src/bindings/range.rs | 4 ++-- yazi-plugin/src/cha/mod.rs | 4 +++- yazi-plugin/src/file/file.rs | 2 +- yazi-plugin/src/file/mod.rs | 4 +++- yazi-plugin/src/loader/mod.rs | 6 ++++-- yazi-plugin/src/pubsub/mod.rs | 4 +++- yazi-plugin/src/runtime.rs | 2 +- yazi-plugin/src/url/mod.rs | 4 +++- yazi-plugin/src/utils/utils.rs | 6 ++++-- 12 files changed, 30 insertions(+), 16 deletions(-) diff --git a/yazi-plugin/src/bindings/bindings.rs b/yazi-plugin/src/bindings/bindings.rs index 3b04e52f..91caff8d 100644 --- a/yazi-plugin/src/bindings/bindings.rs +++ b/yazi-plugin/src/bindings/bindings.rs @@ -1,3 +1,5 @@ +use mlua::Lua; + pub trait Cast { - fn cast(lua: &mlua::Lua, data: T) -> mlua::Result; + fn cast(lua: &Lua, data: T) -> mlua::Result; } diff --git a/yazi-plugin/src/bindings/permit.rs b/yazi-plugin/src/bindings/permit.rs index bb975f06..2d16037f 100644 --- a/yazi-plugin/src/bindings/permit.rs +++ b/yazi-plugin/src/bindings/permit.rs @@ -3,7 +3,7 @@ use std::{mem, ops::Deref}; use mlua::{UserData, prelude::LuaUserDataMethods}; use tokio::sync::SemaphorePermit; -pub type PermitRef<'lua, F> = mlua::UserDataRef>; +pub type PermitRef = mlua::UserDataRef>; pub struct Permit { inner: Option>, diff --git a/yazi-plugin/src/bindings/position.rs b/yazi-plugin/src/bindings/position.rs index f45bea9a..95aa033c 100644 --- a/yazi-plugin/src/bindings/position.rs +++ b/yazi-plugin/src/bindings/position.rs @@ -1,6 +1,6 @@ use std::{ops::Deref, str::FromStr}; -use mlua::{ExternalResult, IntoLua}; +use mlua::{ExternalResult, IntoLua, Lua}; pub struct Position(yazi_config::popup::Position); @@ -33,7 +33,7 @@ impl TryFrom for Position { } impl IntoLua for Position { - fn into_lua(self, lua: &mlua::Lua) -> mlua::Result { + fn into_lua(self, lua: &Lua) -> mlua::Result { lua .create_table_from([ (1.into_lua(lua)?, self.origin.to_string().into_lua(lua)?), diff --git a/yazi-plugin/src/bindings/range.rs b/yazi-plugin/src/bindings/range.rs index 7433e06b..aa864e04 100644 --- a/yazi-plugin/src/bindings/range.rs +++ b/yazi-plugin/src/bindings/range.rs @@ -1,4 +1,4 @@ -use mlua::IntoLua; +use mlua::{IntoLua, Lua}; pub struct Range(std::ops::Range); @@ -10,7 +10,7 @@ impl IntoLua for Range where T: IntoLua, { - fn into_lua(self, lua: &mlua::Lua) -> mlua::Result { + fn into_lua(self, lua: &Lua) -> mlua::Result { lua.create_sequence_from([self.0.start, self.0.end])?.into_lua(lua) } } diff --git a/yazi-plugin/src/cha/mod.rs b/yazi-plugin/src/cha/mod.rs index 011a648d..60e8ee9f 100644 --- a/yazi-plugin/src/cha/mod.rs +++ b/yazi-plugin/src/cha/mod.rs @@ -1,8 +1,10 @@ #![allow(clippy::module_inception)] +use mlua::Lua; + yazi_macro::mod_flat!(cha); -pub fn pour(lua: &mlua::Lua) -> mlua::Result<()> { +pub fn pour(lua: &Lua) -> mlua::Result<()> { cha::Cha::register(lua)?; cha::Cha::install(lua)?; diff --git a/yazi-plugin/src/file/file.rs b/yazi-plugin/src/file/file.rs index e20c587c..61de7b68 100644 --- a/yazi-plugin/src/file/file.rs +++ b/yazi-plugin/src/file/file.rs @@ -2,7 +2,7 @@ use mlua::{AnyUserData, Lua, Table, UserDataRef}; use crate::{bindings::Cast, impl_file_fields, impl_file_methods}; -pub type FileRef<'lua> = UserDataRef; +pub type FileRef = UserDataRef; pub struct File; diff --git a/yazi-plugin/src/file/mod.rs b/yazi-plugin/src/file/mod.rs index cf584692..640debc4 100644 --- a/yazi-plugin/src/file/mod.rs +++ b/yazi-plugin/src/file/mod.rs @@ -1,8 +1,10 @@ #![allow(clippy::module_inception)] +use mlua::Lua; + yazi_macro::mod_flat!(file); -pub fn pour(lua: &mlua::Lua) -> mlua::Result<()> { +pub fn pour(lua: &Lua) -> mlua::Result<()> { file::File::register(lua)?; file::File::install(lua)?; diff --git a/yazi-plugin/src/loader/mod.rs b/yazi-plugin/src/loader/mod.rs index e81e9464..edd311bc 100644 --- a/yazi-plugin/src/loader/mod.rs +++ b/yazi-plugin/src/loader/mod.rs @@ -1,9 +1,11 @@ #![allow(clippy::module_inception)] +use mlua::Lua; + yazi_macro::mod_flat!(loader require); pub(super) fn init() { LOADER.with(<_>::default); } -pub(super) fn install(lua: &mlua::Lua) -> mlua::Result<()> { Require::install(lua) } +pub(super) fn install(lua: &Lua) -> mlua::Result<()> { Require::install(lua) } -pub(super) fn install_isolate(lua: &mlua::Lua) -> mlua::Result<()> { Require::install_isolate(lua) } +pub(super) fn install_isolate(lua: &Lua) -> mlua::Result<()> { Require::install_isolate(lua) } diff --git a/yazi-plugin/src/pubsub/mod.rs b/yazi-plugin/src/pubsub/mod.rs index 5d087d04..ce42b0db 100644 --- a/yazi-plugin/src/pubsub/mod.rs +++ b/yazi-plugin/src/pubsub/mod.rs @@ -1,8 +1,10 @@ #![allow(clippy::module_inception)] +use mlua::Lua; + yazi_macro::mod_flat!(pubsub); -pub(super) fn install(lua: &'static mlua::Lua) -> mlua::Result<()> { +pub(super) fn install(lua: &'static Lua) -> mlua::Result<()> { Pubsub::install(lua)?; Ok(()) diff --git a/yazi-plugin/src/runtime.rs b/yazi-plugin/src/runtime.rs index 2da61719..3f4c8957 100644 --- a/yazi-plugin/src/runtime.rs +++ b/yazi-plugin/src/runtime.rs @@ -13,7 +13,7 @@ struct RuntimeFrame { calls: usize, } -pub type RtRef<'lua> = mlua::UserDataRefMut; +pub type RtRef = mlua::UserDataRefMut; impl Runtime { pub fn new(id: &str) -> Self { diff --git a/yazi-plugin/src/url/mod.rs b/yazi-plugin/src/url/mod.rs index ba07b8b8..4afe04c7 100644 --- a/yazi-plugin/src/url/mod.rs +++ b/yazi-plugin/src/url/mod.rs @@ -1,8 +1,10 @@ #![allow(clippy::module_inception)] +use mlua::Lua; + yazi_macro::mod_flat!(url); -pub fn pour(lua: &mlua::Lua) -> mlua::Result<()> { +pub fn pour(lua: &Lua) -> mlua::Result<()> { url::Url::register(lua)?; url::Url::install(lua)?; diff --git a/yazi-plugin/src/utils/utils.rs b/yazi-plugin/src/utils/utils.rs index 929284c8..8cc7164d 100644 --- a/yazi-plugin/src/utils/utils.rs +++ b/yazi-plugin/src/utils/utils.rs @@ -1,9 +1,11 @@ +use mlua::Lua; + #[cfg(unix)] pub(super) static HOSTNAME_CACHE: std::sync::OnceLock> = std::sync::OnceLock::new(); pub(super) struct Utils; -pub fn install(lua: &'static mlua::Lua) -> mlua::Result<()> { +pub fn install(lua: &'static Lua) -> mlua::Result<()> { let ya = lua.create_table()?; Utils::app(lua, &ya)?; @@ -22,7 +24,7 @@ pub fn install(lua: &'static mlua::Lua) -> mlua::Result<()> { lua.globals().raw_set("ya", ya) } -pub fn install_isolate(lua: &mlua::Lua) -> mlua::Result<()> { +pub fn install_isolate(lua: &Lua) -> mlua::Result<()> { let ya = lua.create_table()?; Utils::app(lua, &ya)?;