Closed patata3000 closed 8 months ago
Hey there!
I've got this piece of code that doesn't work:
let table_obj: LuaTable = build_table_output(buffer.clone(), buffer_content)?; let my_function = Function::from_fn({ move |()| { print!("{:?}", table_obj.call_method("get_cell", ())?); Ok::<(), oxi::Error>(()) } }); buffer.set_keymap(Mode::Normal, "p", my_function, &keymap_opts)?; // FORBIDDEN
I couldn't find a way to pass a lambda LuaFunction to a set_keymap.
LuaFunction
set_keymap
What I could do is to define a LuaFunction in some module -> my_module => my_module.my_function and make
my_module
my_module.my_function
buffer.set_keymap(Mode::Normal, "p", "<cmd>lua require'my_module.my_function()'<cr>", &keymap_opts)?;
There is still a problem though. I want it to either:
table_obj
If it's possible, I can't find a way to do this. If it's not possible, I may be using a bad pattern but I don't know how to solve this problem.
Do you have an explanation? Or any hint?
You can leave the rhs empty and pass the closure to the callback method of your keymap_opts builder.
rhs
callback
keymap_opts
I love you.
Hey there!
I've got this piece of code that doesn't work:
I couldn't find a way to pass a lambda
LuaFunction
to aset_keymap
.What I could do is to define a
LuaFunction
in some module ->my_module
=>my_module.my_function
and makeThere is still a problem though. I want it to either:
table_obj
,table_obj
as an argument.If it's possible, I can't find a way to do this. If it's not possible, I may be using a bad pattern but I don't know how to solve this problem.
Do you have an explanation? Or any hint?