mirror of
https://github.com/noib3/nvim-oxi.git
synced 2025-12-23 06:30:57 +00:00
feat(api): implement mlua::{Into,From}Lua for Buffer, Window and TabPage (#276)
Some checks failed
ci / test (--features neovim-0-10, v0.10.4, macos-latest) (push) Has been cancelled
ci / test (--features neovim-0-10, v0.10.4, ubuntu-latest) (push) Has been cancelled
ci / test (--features neovim-0-10, v0.10.4, windows-latest) (push) Has been cancelled
ci / test (--features neovim-0-11, v0.11.4, macos-latest) (push) Has been cancelled
ci / test (--features neovim-0-11, v0.11.4, ubuntu-latest) (push) Has been cancelled
ci / test (--features neovim-0-11, v0.11.4, windows-latest) (push) Has been cancelled
ci / test (--features neovim-nightly, Nightly, macos-latest) (push) Has been cancelled
ci / test (--features neovim-nightly, Nightly, ubuntu-latest) (push) Has been cancelled
ci / test (--features neovim-nightly, Nightly, windows-latest) (push) Has been cancelled
ci / clippy (push) Has been cancelled
ci / docs (push) Has been cancelled
ci / format (push) Has been cancelled
Some checks failed
ci / test (--features neovim-0-10, v0.10.4, macos-latest) (push) Has been cancelled
ci / test (--features neovim-0-10, v0.10.4, ubuntu-latest) (push) Has been cancelled
ci / test (--features neovim-0-10, v0.10.4, windows-latest) (push) Has been cancelled
ci / test (--features neovim-0-11, v0.11.4, macos-latest) (push) Has been cancelled
ci / test (--features neovim-0-11, v0.11.4, ubuntu-latest) (push) Has been cancelled
ci / test (--features neovim-0-11, v0.11.4, windows-latest) (push) Has been cancelled
ci / test (--features neovim-nightly, Nightly, macos-latest) (push) Has been cancelled
ci / test (--features neovim-nightly, Nightly, ubuntu-latest) (push) Has been cancelled
ci / test (--features neovim-nightly, Nightly, windows-latest) (push) Has been cancelled
ci / clippy (push) Has been cancelled
ci / docs (push) Has been cancelled
ci / format (push) Has been cancelled
This commit is contained in:
parent
36cbc26f2a
commit
fef0f72702
5 changed files with 62 additions and 6 deletions
|
|
@ -19,6 +19,8 @@ luajit = { path = "./crates/luajit", package = "nvim-oxi-luajit" }
|
|||
macros = { path = "./crates/macros", package = "nvim-oxi-macros" }
|
||||
types = { path = "./crates/types", package = "nvim-oxi-types" }
|
||||
|
||||
cargo_metadata = { version = "0.23" }
|
||||
mlua = { version = "0.11", features = ["luajit"] }
|
||||
thiserror = "2.0"
|
||||
|
||||
[workspace.lints.clippy]
|
||||
|
|
@ -59,7 +61,7 @@ __docsrs = ["mlua?/vendored"]
|
|||
__no_docsrs = ["mlua?/module"]
|
||||
|
||||
libuv = ["dep:libuv"]
|
||||
mlua = ["dep:mlua"]
|
||||
mlua = ["api/mlua", "dep:mlua"]
|
||||
test = ["macros/test", "dep:cargo_metadata"]
|
||||
test-terminator = ["test", "libuv", "macros/test-terminator"]
|
||||
|
||||
|
|
@ -70,9 +72,9 @@ macros = { workspace = true, features = ["plugin"] }
|
|||
types = { workspace = true, features = ["serde"] }
|
||||
libuv = { workspace = true, optional = true }
|
||||
|
||||
cargo_metadata = { workspace = true, optional = true }
|
||||
mlua = { workspace = true, optional = true }
|
||||
thiserror = { workspace = true }
|
||||
cargo_metadata = { version = "0.21", optional = true }
|
||||
mlua = { version = "0.11", features = ["luajit"], optional = true }
|
||||
|
||||
[dev-dependencies]
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
|
|
|
|||
|
|
@ -10,10 +10,20 @@ repository.workspace = true
|
|||
license.workspace = true
|
||||
keywords.workspace = true
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
default-features = false
|
||||
features = ["__docsrs", "neovim-nightly", "mlua"]
|
||||
rustdoc-args = ["--cfg", "docsrs"]
|
||||
|
||||
[features]
|
||||
default = ["__no_docsrs"]
|
||||
neovim-0-10 = []
|
||||
neovim-0-11 = ["neovim-0-10"]
|
||||
neovim-nightly = ["neovim-0-11"]
|
||||
mlua = ["dep:mlua"]
|
||||
|
||||
__docsrs = ["mlua?/vendored"]
|
||||
__no_docsrs = ["mlua?/module"]
|
||||
|
||||
[dependencies]
|
||||
luajit = { workspace = true }
|
||||
|
|
@ -23,5 +33,7 @@ serde_repr = "0.1"
|
|||
thiserror = { workspace = true }
|
||||
types = { workspace = true, features = ["serde"] }
|
||||
|
||||
mlua = { workspace = true, optional = true }
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
|
|
|||
|
|
@ -87,6 +87,20 @@ impl Pushable for Buffer {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "mlua")]
|
||||
impl mlua::IntoLua for Buffer {
|
||||
fn into_lua(self, lua: &mlua::Lua) -> mlua::Result<mlua::Value> {
|
||||
self.handle().into_lua(lua)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "mlua")]
|
||||
impl mlua::FromLua for Buffer {
|
||||
fn from_lua(value: mlua::Value, lua: &mlua::Lua) -> mlua::Result<Self> {
|
||||
BufHandle::from_lua(value, lua).map(Into::into)
|
||||
}
|
||||
}
|
||||
|
||||
impl Buffer {
|
||||
/// Shorthand for [`get_current_buf`](crate::get_current_buf).
|
||||
#[inline(always)]
|
||||
|
|
@ -94,7 +108,7 @@ impl Buffer {
|
|||
crate::get_current_buf()
|
||||
}
|
||||
|
||||
/// Retrieve buffer's underlying id/handle
|
||||
/// Returns the buffer's underlying handle.
|
||||
#[inline(always)]
|
||||
pub fn handle(&self) -> i32 {
|
||||
self.0
|
||||
|
|
|
|||
|
|
@ -67,6 +67,20 @@ impl FromObject for TabPage {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "mlua")]
|
||||
impl mlua::IntoLua for TabPage {
|
||||
fn into_lua(self, lua: &mlua::Lua) -> mlua::Result<mlua::Value> {
|
||||
self.handle().into_lua(lua)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "mlua")]
|
||||
impl mlua::FromLua for TabPage {
|
||||
fn from_lua(value: mlua::Value, lua: &mlua::Lua) -> mlua::Result<Self> {
|
||||
TabHandle::from_lua(value, lua).map(Into::into)
|
||||
}
|
||||
}
|
||||
|
||||
impl TabPage {
|
||||
/// Shorthand for [`get_current_tabpage`](crate::get_current_tabpage).
|
||||
#[inline(always)]
|
||||
|
|
@ -74,7 +88,7 @@ impl TabPage {
|
|||
crate::get_current_tabpage()
|
||||
}
|
||||
|
||||
/// Retrieve tabpage's underlying id/handle
|
||||
/// Returns the tabpage's underlying handle.
|
||||
#[inline(always)]
|
||||
pub fn handle(&self) -> i32 {
|
||||
self.0
|
||||
|
|
|
|||
|
|
@ -78,6 +78,20 @@ impl Pushable for Window {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "mlua")]
|
||||
impl mlua::IntoLua for Window {
|
||||
fn into_lua(self, lua: &mlua::Lua) -> mlua::Result<mlua::Value> {
|
||||
self.handle().into_lua(lua)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "mlua")]
|
||||
impl mlua::FromLua for Window {
|
||||
fn from_lua(value: mlua::Value, lua: &mlua::Lua) -> mlua::Result<Self> {
|
||||
WinHandle::from_lua(value, lua).map(Into::into)
|
||||
}
|
||||
}
|
||||
|
||||
impl Window {
|
||||
/// Shorthand for [`get_current_win`](crate::get_current_win).
|
||||
#[inline(always)]
|
||||
|
|
@ -85,7 +99,7 @@ impl Window {
|
|||
crate::get_current_win()
|
||||
}
|
||||
|
||||
/// Retrieve window's underlying id/handle
|
||||
/// Returns the window's underlying handle.
|
||||
#[inline(always)]
|
||||
pub fn handle(&self) -> i32 {
|
||||
self.0
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue