Skip to content
This repository has been archived by the owner on Jul 13, 2023. It is now read-only.

Commit

Permalink
Fixed all doc issues!
Browse files Browse the repository at this point in the history
  • Loading branch information
willothy committed Feb 21, 2023
1 parent c8e1461 commit 5cb30ae
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 17 deletions.
4 changes: 3 additions & 1 deletion src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ use std::future::Future;
/// let module = builder.build()?;
///
/// // If you need to return a LuaValue instead of a LuaTable, you can use mlua's `to_lua` method instead of `build`
/// let value = builder.to_lua(lua)?;
/// // let value = builder.to_lua(lua)?;
///
/// Ok(module)
/// }
/// ```
#[derive(Debug)]
Expand Down
11 changes: 8 additions & 3 deletions src/vim/ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,18 @@ use std::path::PathBuf;
///
/// ## Example
/// ```rust
/// use crate::prelude::*;
/// vim::ext::mksession(lua, PathBuf::from("~/.sessions/session.vim"))?;
/// use nvim_utils::prelude::*;
/// use std::path::PathBuf;
///
/// fn my_module(lua: &Lua) -> LuaResult<()> {
/// vim::ext::mksession(lua, PathBuf::from("~/.sessions/session.vim"))?;
/// Ok(())
/// }
/// ```
pub fn mksession<'a>(lua: &Lua, path: PathBuf) -> LuaResult<()> {
vim::cmd(
lua,
format!("mksession! {}", String::from(path.to_string_lossy())),
&format!("mksession! {}", String::from(path.to_string_lossy())),
)
}

Expand Down
28 changes: 15 additions & 13 deletions src/vim/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@ use crate::prelude::*;
///
/// ## Example
/// ```rust
/// use crate::prelude::*;
/// fn my_module(lua: &Lua) -> LuaResult<()> {
/// let vim = vim::get(lua)?;
/// let vim_version = vim.call_function("version", ())?;
/// println!("Vim version: {}", vim::inspect(lua, vim_version));
/// use nvim_utils::prelude::*;
/// fn my_module(lua: &mlua::prelude::Lua) -> mlua::prelude::LuaResult<()> {
/// let global_vim = vim::get(lua)?;
/// let vim_version: LuaTable = global_vim.call_function("version", ())?;
/// println!("Vim version: {}", vim::inspect(lua, vim_version)?);
/// Ok(())
/// }
/// ```
pub fn get(lua: &Lua) -> LuaResult<LuaTable> {
Expand All @@ -33,25 +34,26 @@ pub fn get(lua: &Lua) -> LuaResult<LuaTable> {
///
/// ## Example
/// ```rust
/// use crate::prelude::*;
/// fn my_module(lua: &Lua) -> LuaResult<()> {
/// use nvim_utils::prelude::*;
/// fn my_module(lua: &mlua::prelude::Lua) -> mlua::prelude::LuaResult<()> {
/// vim::cmd(lua, "echo 'Hello, world!'")?;
/// vim::cmd(lua, "terminal")?;
/// vim::cmd(lua, "terminal")
/// }
/// ```
pub fn cmd(lua: &Lua, cmd: String) -> LuaResult<()> {
pub fn cmd(lua: &Lua, cmd: &str) -> LuaResult<()> {
self::get(lua)?.call_function("cmd", cmd)
}

/// Corresponds to `vim.inspect()`
///
/// ## Example
/// ```rust
/// use crate::prelude::*;
/// use nvim_utils::prelude::*;
/// fn my_module(lua: &Lua) -> LuaResult<()> {
/// let table = lua.create_table()?;
/// table.set("foo", "bar")?;
/// let inspect = vim::inspect(lua, table)?;
/// Ok(())
/// }
/// ```
pub fn inspect<'a>(lua: &'a Lua, value: impl ToLua<'a>) -> LuaResult<String> {
Expand All @@ -62,9 +64,9 @@ pub fn inspect<'a>(lua: &'a Lua, value: impl ToLua<'a>) -> LuaResult<String> {
///
/// ## Example
/// ```rust
/// use crate::prelude::*;
/// fn my_module(lua: &Lua) -> LuaResult<()> {
/// vim::notify(lua, "Loaded module!", vim::log::LogLevel::Info)?
/// use nvim_utils::prelude::*;
/// fn my_module(lua: &mlua::prelude::Lua) -> mlua::prelude::LuaResult<()> {
/// vim::notify(lua, "Loaded module!", vim::log::LogLevel::Info)
/// }
/// ```
pub fn notify(lua: &Lua, msg: &str, log_level: log::LogLevel) -> LuaResult<()> {
Expand Down

0 comments on commit 5cb30ae

Please sign in to comment.