mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
feat: allow overriding and rewriting the sync methods of builtin plugins (#1695)
This commit is contained in:
parent
70fbe41cc2
commit
3e4973dbbf
2 changed files with 22 additions and 14 deletions
8
.github/ISSUE_TEMPLATE/feature.yml
vendored
8
.github/ISSUE_TEMPLATE/feature.yml
vendored
|
|
@ -43,7 +43,7 @@ body:
|
||||||
label: Validations
|
label: Validations
|
||||||
description: Before submitting the issue, please make sure you have completed the following
|
description: Before submitting the issue, please make sure you have completed the following
|
||||||
options:
|
options:
|
||||||
- label: I have searched the existing issues
|
- label: I have searched the existing issues/discussions
|
||||||
required: true
|
required: true
|
||||||
- label: The latest nightly build of Yazi doesn't already have this feature
|
- label: The latest nightly build of Yazi doesn't already have this feature
|
||||||
required: true
|
required: true
|
||||||
|
|
|
||||||
|
|
@ -42,17 +42,25 @@ impl Require {
|
||||||
|
|
||||||
fn create_mt<'a>(lua: &'a Lua, id: &str, mod_: Table<'a>, sync: bool) -> mlua::Result<Table<'a>> {
|
fn create_mt<'a>(lua: &'a Lua, id: &str, mod_: Table<'a>, sync: bool) -> mlua::Result<Table<'a>> {
|
||||||
let id: Arc<str> = Arc::from(id);
|
let id: Arc<str> = Arc::from(id);
|
||||||
let mt = lua.create_table_from([(
|
let mt = lua.create_table_from([
|
||||||
"__index",
|
(
|
||||||
lua.create_function(move |lua, (ts, key): (Table, mlua::String)| {
|
"__index",
|
||||||
match ts.raw_get::<_, Table>("__mod")?.raw_get::<_, Value>(&key)? {
|
lua.create_function(move |lua, (ts, key): (Table, mlua::String)| {
|
||||||
Value::Function(_) => {
|
match ts.raw_get::<_, Table>("__mod")?.raw_get::<_, Value>(&key)? {
|
||||||
Self::create_wrapper(lua, id.clone(), key.to_str()?, sync)?.into_lua(lua)
|
Value::Function(_) => {
|
||||||
|
Self::create_wrapper(lua, id.clone(), key.to_str()?, sync)?.into_lua(lua)
|
||||||
|
}
|
||||||
|
v => Ok(v),
|
||||||
}
|
}
|
||||||
v => Ok(v),
|
})?,
|
||||||
}
|
),
|
||||||
})?,
|
(
|
||||||
)])?;
|
"__newindex",
|
||||||
|
lua.create_function(move |_, (ts, key, value): (Table, mlua::String, Value)| {
|
||||||
|
ts.raw_get::<_, Table>("__mod")?.raw_set(key, value)
|
||||||
|
})?,
|
||||||
|
),
|
||||||
|
])?;
|
||||||
|
|
||||||
let ts = lua.create_table_from([("__mod", mod_)])?;
|
let ts = lua.create_table_from([("__mod", mod_)])?;
|
||||||
ts.set_metatable(Some(mt));
|
ts.set_metatable(Some(mt));
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue