nvim_oxi_api/
lib.rs

1//! This module contains the bindings to the [Neovim
2//! API](https://neovim.io/doc/user/api.html), exposed in Lua through the
3//! `vim.api` table.
4//!
5//! # Naming convention
6//!
7//! All the functions have been renamed by dropping the leading `nvim_` prefix,
8//! e.g. `nvim_get_current_buf` simply becomes [`get_current_buf`].
9//!
10//! Also, the functions starting with `nvim_buf_*`, `nvim_win_*` and
11//! `nvim_tabpage_*` are implemented as methods on the [`Buffer`], [`Window`]
12//! and [`TabPage`] objects respectively.
13
14#![cfg_attr(docsrs, feature(doc_cfg))]
15
16mod autocmd;
17mod buffer;
18mod command;
19mod deprecated;
20mod error;
21mod extmark;
22mod ffi;
23mod options;
24pub mod opts;
25pub(crate) mod serde_utils;
26mod tabpage;
27mod trait_utils;
28pub mod types;
29pub(crate) mod utils;
30mod vim;
31mod vimscript;
32mod win_config;
33mod window;
34
35pub use autocmd::*;
36pub use buffer::*;
37pub use command::*;
38pub use deprecated::*;
39pub use error::Error;
40use error::Result;
41pub use extmark::*;
42pub use luajit::IntoResult;
43pub use options::*;
44pub use tabpage::*;
45pub use trait_utils::*;
46pub use vim::*;
47pub use vimscript::*;
48pub use win_config::*;
49pub use window::*;
50
51// https://github.com/neovim/neovim/blob/v0.9.0/src/nvim/api/private/defs.h#L43
52const INTERNAL_CALL_MASK: u64 = 1u64 << (std::mem::size_of::<u64>() * 8 - 1);
53
54// https://github.com/neovim/neovim/blob/v0.9.0/src/nvim/api/private/defs.h#L46
55const VIML_INTERNAL_CALL: u64 = INTERNAL_CALL_MASK;
56
57// https://github.com/neovim/neovim/blob/v0.9.0/src/nvim/api/private/defs.h#L49
58const LUA_INTERNAL_CALL: u64 = VIML_INTERNAL_CALL + 1;
59
60macro_rules! choose {
61    ($err:expr, ()) => {
62        if $err.is_err() {
63            Err($err.into())
64        } else {
65            Ok(())
66        }
67    };
68
69    ($err:expr, $other:expr) => {
70        if $err.is_err() {
71            Err($err.into())
72        } else {
73            $other
74        }
75    };
76}
77
78pub(crate) use choose;