nvim_oxi/lib.rs
1//! # Rust bindings to all things Neovim
2//!
3//! This library provides safe bindings to the API exposed by the [Neovim] text
4//! editor.
5//!
6//! [Neovim]: https://neovim.io
7
8#![doc(html_root_url = "https://docs.rs/nvim_oxi/latest")]
9#![cfg_attr(docsrs, feature(doc_cfg))]
10#![deny(future_incompatible)]
11#![deny(nonstandard_style)]
12#![deny(rustdoc::broken_intra_doc_links)]
13
14#[doc(hidden)]
15pub mod entrypoint;
16mod error;
17mod toplevel;
18
19pub mod api {
20 //! Bindings to the [Neovim C API][api].
21 //!
22 //! [api]: https://neovim.io/doc/user/api.html
23 #[doc(inline)]
24 pub use api::*;
25}
26
27#[cfg(feature = "libuv")]
28#[cfg_attr(docsrs, doc(cfg(feature = "libuv")))]
29pub mod libuv {
30 //! Bindings to the [Neovim event loop][loop] powered by [libuv].
31 //!
32 //! [loop]: https://neovim.io/doc/user/lua.html#vim.loop
33 //! [libuv]: https://libuv.org/
34 #[doc(inline)]
35 pub use libuv::*;
36}
37
38pub mod lua {
39 //! Low-level Rust bindings to [LuaJIT], the Lua version used by Neovim.
40 //!
41 //! [LuaJIT]: https://luajit.org/
42 #[doc(inline)]
43 pub use luajit::*;
44}
45
46#[cfg(feature = "mlua")]
47#[cfg_attr(docsrs, doc(cfg(feature = "mlua")))]
48pub mod mlua {
49 //! Integrations with the [mlua] Rust crate providing safe Lua bindings.
50 //!
51 //! [mlua]: https://github.com/khvzak/mlua
52
53 pub use mlua::*;
54
55 /// Returns a
56 /// [`mlua::Lua`](https://docs.rs/mlua/latest/mlua/struct.Lua.html)
57 /// instance which can be used to interact with Lua plugins.
58 ///
59 /// # Examples
60 ///
61 /// ```ignore
62 /// use mlua::prelude::LuaFunction;
63 /// use nvim_oxi as nvim;
64 ///
65 /// #[nvim::plugin]
66 /// fn mlua() -> nvim::Result<()> {
67 /// nvim::print!("Hello from nvim-oxi..");
68 ///
69 /// let lua = nvim::mlua::lua();
70 /// let print = lua.globals().get::<_, LuaFunction>("print")?;
71 /// print.call("..and goodbye from mlua!")?;
72 ///
73 /// Ok(())
74 /// }
75 /// ```
76 pub fn lua() -> mlua::Lua {
77 unsafe {
78 luajit::with_state(|lua_state| {
79 mlua::Lua::init_from_ptr(lua_state as *mut _)
80 })
81 }
82 }
83}
84
85pub use error::{Error, Result};
86pub use luajit::{IntoResult, dbg, print};
87pub use macros::plugin;
88#[cfg(feature = "test")]
89#[cfg_attr(docsrs, doc(cfg(feature = "test")))]
90pub use macros::test;
91pub use types::*;
92#[cfg(feature = "test")]
93pub mod tests;
94pub use toplevel::*;
95pub use types::string;