mirror of
https://github.com/noib3/nvim-oxi.git
synced 2025-08-04 19:08:31 +00:00
✨ feat: add mlua
integration
This commit is contained in:
parent
456d44793f
commit
71e8f28ad6
9 changed files with 67 additions and 3 deletions
11
examples/mlua/.cargo/config
Normal file
11
examples/mlua/.cargo/config
Normal file
|
@ -0,0 +1,11 @@
|
|||
[target.x86_64-apple-darwin]
|
||||
rustflags = [
|
||||
"-C", "link-arg=-undefined",
|
||||
"-C", "link-arg=dynamic_lookup",
|
||||
]
|
||||
|
||||
[target.aarch64-apple-darwin]
|
||||
rustflags = [
|
||||
"-C", "link-arg=-undefined",
|
||||
"-C", "link-arg=dynamic_lookup",
|
||||
]
|
11
examples/mlua/Cargo.toml
Normal file
11
examples/mlua/Cargo.toml
Normal file
|
@ -0,0 +1,11 @@
|
|||
[package]
|
||||
name = "lua"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[lib]
|
||||
crate-type = ["cdylib"]
|
||||
|
||||
[dependencies]
|
||||
nvim-oxi = { path = "../../nvim-oxi", features = ["mlua"] }
|
||||
mlua = { version = "0.8", features = ["luajit"] }
|
4
examples/mlua/README.md
Normal file
4
examples/mlua/README.md
Normal file
|
@ -0,0 +1,4 @@
|
|||
# mlua
|
||||
|
||||
`require("lua").greetings()` will print `"Hello from Rust.."` followed by
|
||||
`"..and goodbye from Lua!"`.
|
17
examples/mlua/src/lib.rs
Normal file
17
examples/mlua/src/lib.rs
Normal file
|
@ -0,0 +1,17 @@
|
|||
use mlua::prelude::LuaFunction;
|
||||
use nvim_oxi::{self as oxi, Dictionary, Function};
|
||||
|
||||
fn greetings(_: ()) -> oxi::Result<()> {
|
||||
oxi::print!("Hello from Rust..");
|
||||
|
||||
let lua = oxi::mlua::lua();
|
||||
let print = lua.globals().get::<_, LuaFunction>("print")?;
|
||||
print.call("..and goodbye from Lua!")?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[oxi::module]
|
||||
fn lua() -> oxi::Result<Dictionary> {
|
||||
Ok(Dictionary::from_iter([("greetings", Function::from_fn(greetings))]))
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue