use std::io;
use rmp::{decode::Bytes, encode::write_array_len};
use tokio::io::AsyncWrite;
use crate::{
api::{ApiCall, ApiCallAndDecode},
neovim::Neovim,
rpc::{
ExtType,
decode::{BytesReaderExt, Decode},
encode::{Encode, EncodeArgs},
},
};
pub const API_LEVEL: u32 = 14;
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub struct Exception<T>(pub T);
impl<'de, T: Decode<'de>> Decode<'de> for Exception<T> {
fn decode(buf: &mut Bytes<'de>) -> io::Result<Self> {
if buf.read_array_len()? != 2 || i64::decode(buf)? != 0 {
return Err(io::ErrorKind::InvalidData.into());
}
T::decode(buf).map(Self)
}
}
impl<T: Encode> Encode for Exception<T> {
fn encode(&self, buf: &mut Vec<u8>) -> io::Result<()> {
write_array_len(buf, 2)?;
0i64.encode(buf)?;
self.0.encode(buf)
}
}
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub struct Validation<T>(pub T);
impl<'de, T: Decode<'de>> Decode<'de> for Validation<T> {
fn decode(buf: &mut Bytes<'de>) -> io::Result<Self> {
if buf.read_array_len()? != 2 || i64::decode(buf)? != 1 {
return Err(io::ErrorKind::InvalidData.into());
}
T::decode(buf).map(Self)
}
}
impl<T: Encode> Encode for Validation<T> {
fn encode(&self, buf: &mut Vec<u8>) -> io::Result<()> {
write_array_len(buf, 2)?;
1i64.encode(buf)?;
self.0.encode(buf)
}
}
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub struct Buffer(i32);
impl Buffer {
pub const CURRENT: Self = Self(0);
}
impl<'de> Decode<'de> for Buffer {
#[inline]
fn decode(buf: &mut Bytes<'de>) -> io::Result<Self> {
ExtType::<0>::decode(buf).map(|value| Self(value.0))
}
}
impl Encode for Buffer {
#[inline]
fn encode(&self, buf: &mut Vec<u8>) -> io::Result<()> {
ExtType::<0>(self.0).encode(buf)
}
}
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub struct Tabpage(i32);
impl Tabpage {
pub const CURRENT: Self = Self(0);
}
impl<'de> Decode<'de> for Tabpage {
#[inline]
fn decode(buf: &mut Bytes<'de>) -> io::Result<Self> {
ExtType::<2>::decode(buf).map(|value| Self(value.0))
}
}
impl Encode for Tabpage {
#[inline]
fn encode(&self, buf: &mut Vec<u8>) -> io::Result<()> {
ExtType::<2>(self.0).encode(buf)
}
}
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub struct Window(i32);
impl Window {
pub const CURRENT: Self = Self(0);
}
impl<'de> Decode<'de> for Window {
#[inline]
fn decode(buf: &mut Bytes<'de>) -> io::Result<Self> {
ExtType::<1>::decode(buf).map(|value| Self(value.0))
}
}
impl Encode for Window {
#[inline]
fn encode(&self, buf: &mut Vec<u8>) -> io::Result<()> {
ExtType::<1>(self.0).encode(buf)
}
}
impl<W: AsyncWrite + Unpin> Neovim<W> {
#[inline]
pub fn get_autocmds(&self, opts: impl Encode) -> ApiCall<'_, W, impl EncodeArgs> {
self.caller.call("nvim_get_autocmds", opts)
}
#[inline]
pub fn create_autocmd(
&self,
event: impl Encode,
opts: impl Encode,
) -> ApiCallAndDecode<'_, W, i64, impl EncodeArgs> {
self.caller
.call_and_decode("nvim_create_autocmd", (event, opts))
}
#[inline]
pub fn del_autocmd(&self, id: i64) -> ApiCallAndDecode<'_, W, (), impl EncodeArgs> {
self.caller.call_and_decode("nvim_del_autocmd", id)
}
#[inline]
pub fn clear_autocmds(
&self,
opts: impl Encode,
) -> ApiCallAndDecode<'_, W, (), impl EncodeArgs> {
self.caller.call_and_decode("nvim_clear_autocmds", opts)
}
#[inline]
pub fn create_augroup(
&self,
name: &str,
opts: impl Encode,
) -> ApiCallAndDecode<'_, W, i64, impl EncodeArgs> {
self.caller
.call_and_decode("nvim_create_augroup", (name, opts))
}
#[inline]
pub fn del_augroup_by_id(&self, id: i64) -> ApiCallAndDecode<'_, W, (), impl EncodeArgs> {
self.caller.call_and_decode("nvim_del_augroup_by_id", id)
}
#[inline]
pub fn del_augroup_by_name(&self, name: &str) -> ApiCallAndDecode<'_, W, (), impl EncodeArgs> {
self.caller
.call_and_decode("nvim_del_augroup_by_name", name)
}
#[inline]
pub fn exec_autocmds(
&self,
event: impl Encode,
opts: impl Encode,
) -> ApiCallAndDecode<'_, W, (), impl EncodeArgs> {
self.caller
.call_and_decode("nvim_exec_autocmds", (event, opts))
}
#[inline]
pub fn buf_line_count(&self, buf: Buffer) -> ApiCallAndDecode<'_, W, i64, impl EncodeArgs> {
self.caller.call_and_decode("nvim_buf_line_count", buf)
}
#[inline]
pub fn buf_attach(
&self,
buf: Buffer,
send_buffer: bool,
opts: impl Encode,
) -> ApiCallAndDecode<'_, W, bool, impl EncodeArgs> {
self.caller
.call_and_decode("nvim_buf_attach", (buf, send_buffer, opts))
}
#[inline]
pub fn buf_detach(&self, buf: Buffer) -> ApiCallAndDecode<'_, W, bool, impl EncodeArgs> {
self.caller.call_and_decode("nvim_buf_detach", buf)
}
#[inline]
pub fn buf_get_lines(
&self,
buf: Buffer,
start: i64,
end: i64,
strict_indexing: bool,
) -> ApiCall<'_, W, impl EncodeArgs> {
self.caller
.call("nvim_buf_get_lines", (buf, start, end, strict_indexing))
}
#[inline]
pub fn buf_set_lines(
&self,
buf: Buffer,
start: i64,
end: i64,
strict_indexing: bool,
replacement: impl Encode,
) -> ApiCallAndDecode<'_, W, (), impl EncodeArgs> {
self.caller.call_and_decode(
"nvim_buf_set_lines",
(buf, start, end, strict_indexing, replacement),
)
}
#[inline]
pub fn buf_set_text(
&self,
buf: Buffer,
start_row: i64,
start_col: i64,
end_row: i64,
end_col: i64,
replacement: impl Encode,
) -> ApiCallAndDecode<'_, W, (), impl EncodeArgs> {
self.caller.call_and_decode(
"nvim_buf_set_text",
(buf, start_row, start_col, end_row, end_col, replacement),
)
}
#[inline]
pub fn buf_get_text(
&self,
buf: Buffer,
start_row: i64,
start_col: i64,
end_row: i64,
end_col: i64,
opts: impl Encode,
) -> ApiCall<'_, W, impl EncodeArgs> {
self.caller.call(
"nvim_buf_get_text",
(buf, start_row, start_col, end_row, end_col, opts),
)
}
#[inline]
pub fn buf_get_offset(
&self,
buf: Buffer,
index: i64,
) -> ApiCallAndDecode<'_, W, i64, impl EncodeArgs> {
self.caller
.call_and_decode("nvim_buf_get_offset", (buf, index))
}
#[inline]
pub fn buf_get_var(&self, buf: Buffer, name: &str) -> ApiCall<'_, W, impl EncodeArgs> {
self.caller.call("nvim_buf_get_var", (buf, name))
}
#[inline]
pub fn buf_get_changedtick(
&self,
buf: Buffer,
) -> ApiCallAndDecode<'_, W, i64, impl EncodeArgs> {
self.caller.call_and_decode("nvim_buf_get_changedtick", buf)
}
#[inline]
pub fn buf_get_keymap(&self, buf: Buffer, mode: &str) -> ApiCall<'_, W, impl EncodeArgs> {
self.caller.call("nvim_buf_get_keymap", (buf, mode))
}
#[inline]
pub fn buf_set_keymap(
&self,
buf: Buffer,
mode: &str,
lhs: &str,
rhs: &str,
opts: impl Encode,
) -> ApiCallAndDecode<'_, W, (), impl EncodeArgs> {
self.caller
.call_and_decode("nvim_buf_set_keymap", (buf, mode, lhs, rhs, opts))
}
#[inline]
pub fn buf_del_keymap(
&self,
buf: Buffer,
mode: &str,
lhs: &str,
) -> ApiCallAndDecode<'_, W, (), impl EncodeArgs> {
self.caller
.call_and_decode("nvim_buf_del_keymap", (buf, mode, lhs))
}
#[inline]
pub fn buf_set_var(
&self,
buf: Buffer,
name: &str,
value: impl Encode,
) -> ApiCallAndDecode<'_, W, (), impl EncodeArgs> {
self.caller
.call_and_decode("nvim_buf_set_var", (buf, name, value))
}
#[inline]
pub fn buf_del_var(
&self,
buf: Buffer,
name: &str,
) -> ApiCallAndDecode<'_, W, (), impl EncodeArgs> {
self.caller.call_and_decode("nvim_buf_del_var", (buf, name))
}
#[inline]
pub fn buf_get_name(&self, buf: Buffer) -> ApiCall<'_, W, impl EncodeArgs> {
self.caller.call("nvim_buf_get_name", buf)
}
#[inline]
pub fn buf_set_name(
&self,
buf: Buffer,
name: &str,
) -> ApiCallAndDecode<'_, W, (), impl EncodeArgs> {
self.caller
.call_and_decode("nvim_buf_set_name", (buf, name))
}
#[inline]
pub fn buf_is_loaded(&self, buf: Buffer) -> ApiCallAndDecode<'_, W, bool, impl EncodeArgs> {
self.caller.call_and_decode("nvim_buf_is_loaded", buf)
}
#[inline]
pub fn buf_delete(
&self,
buf: Buffer,
opts: impl Encode,
) -> ApiCallAndDecode<'_, W, (), impl EncodeArgs> {
self.caller.call_and_decode("nvim_buf_delete", (buf, opts))
}
#[inline]
pub fn buf_is_valid(&self, buf: Buffer) -> ApiCallAndDecode<'_, W, bool, impl EncodeArgs> {
self.caller.call_and_decode("nvim_buf_is_valid", buf)
}
#[inline]
pub fn buf_del_mark(
&self,
buf: Buffer,
name: &str,
) -> ApiCallAndDecode<'_, W, bool, impl EncodeArgs> {
self.caller
.call_and_decode("nvim_buf_del_mark", (buf, name))
}
#[inline]
pub fn buf_set_mark(
&self,
buf: Buffer,
name: &str,
line: i64,
col: i64,
opts: impl Encode,
) -> ApiCallAndDecode<'_, W, bool, impl EncodeArgs> {
self.caller
.call_and_decode("nvim_buf_set_mark", (buf, name, line, col, opts))
}
#[inline]
pub fn buf_get_mark(&self, buf: Buffer, name: &str) -> ApiCall<'_, W, impl EncodeArgs> {
self.caller.call("nvim_buf_get_mark", (buf, name))
}
#[inline]
pub fn buf_call(&self, buf: Buffer, fun: impl Encode) -> ApiCall<'_, W, impl EncodeArgs> {
self.caller.call("nvim_buf_call", (buf, fun))
}
#[inline]
pub fn parse_cmd(&self, str: &str, opts: impl Encode) -> ApiCall<'_, W, impl EncodeArgs> {
self.caller.call("nvim_parse_cmd", (str, opts))
}
#[inline]
pub fn cmd(&self, cmd: impl Encode, opts: impl Encode) -> ApiCall<'_, W, impl EncodeArgs> {
self.caller.call("nvim_cmd", (cmd, opts))
}
#[inline]
pub fn create_user_command(
&self,
name: &str,
cmd: impl Encode,
opts: impl Encode,
) -> ApiCallAndDecode<'_, W, (), impl EncodeArgs> {
self.caller
.call_and_decode("nvim_create_user_command", (name, cmd, opts))
}
#[inline]
pub fn del_user_command(&self, name: &str) -> ApiCallAndDecode<'_, W, (), impl EncodeArgs> {
self.caller.call_and_decode("nvim_del_user_command", name)
}
#[inline]
pub fn buf_create_user_command(
&self,
buf: Buffer,
name: &str,
cmd: impl Encode,
opts: impl Encode,
) -> ApiCallAndDecode<'_, W, (), impl EncodeArgs> {
self.caller
.call_and_decode("nvim_buf_create_user_command", (buf, name, cmd, opts))
}
#[inline]
pub fn buf_del_user_command(
&self,
buf: Buffer,
name: &str,
) -> ApiCallAndDecode<'_, W, (), impl EncodeArgs> {
self.caller
.call_and_decode("nvim_buf_del_user_command", (buf, name))
}
#[inline]
pub fn get_commands(&self, opts: impl Encode) -> ApiCall<'_, W, impl EncodeArgs> {
self.caller.call("nvim_get_commands", opts)
}
#[inline]
pub fn buf_get_commands(
&self,
buf: Buffer,
opts: impl Encode,
) -> ApiCall<'_, W, impl EncodeArgs> {
self.caller.call("nvim_buf_get_commands", (buf, opts))
}
#[deprecated = "this method was deprecated since Neovim API level 11"]
#[inline]
pub fn exec(&self, src: &str, output: bool) -> ApiCall<'_, W, impl EncodeArgs> {
self.caller.call("nvim_exec", (src, output))
}
#[deprecated = "this method was deprecated since Neovim API level 7"]
#[inline]
pub fn command_output(&self, command: &str) -> ApiCall<'_, W, impl EncodeArgs> {
self.caller.call("nvim_command_output", command)
}
#[deprecated = "this method was deprecated since Neovim API level 7"]
#[inline]
pub fn execute_lua(&self, code: &str, args: impl Encode) -> ApiCall<'_, W, impl EncodeArgs> {
self.caller.call("nvim_execute_lua", (code, args))
}
#[deprecated = "this method was deprecated since Neovim API level 2"]
#[inline]
pub fn buf_get_number(&self, buffer: Buffer) -> ApiCallAndDecode<'_, W, i64, impl EncodeArgs> {
self.caller.call_and_decode("nvim_buf_get_number", buffer)
}
#[deprecated = "this method was deprecated since Neovim API level 7"]
#[inline]
pub fn buf_clear_highlight(
&self,
buffer: Buffer,
ns_id: i64,
line_start: i64,
line_end: i64,
) -> ApiCallAndDecode<'_, W, (), impl EncodeArgs> {
self.caller.call_and_decode(
"nvim_buf_clear_highlight",
(buffer, ns_id, line_start, line_end),
)
}
#[deprecated = "this method was deprecated since Neovim API level 13"]
#[inline]
pub fn buf_add_highlight(
&self,
buffer: Buffer,
ns_id: i64,
hl_group: &str,
line: i64,
col_start: i64,
col_end: i64,
) -> ApiCallAndDecode<'_, W, i64, impl EncodeArgs> {
self.caller.call_and_decode(
"nvim_buf_add_highlight",
(buffer, ns_id, hl_group, line, col_start, col_end),
)
}
#[deprecated = "this method was deprecated since Neovim API level 8"]
#[inline]
pub fn buf_set_virtual_text(
&self,
buffer: Buffer,
src_id: i64,
line: i64,
chunks: impl Encode,
opts: impl Encode,
) -> ApiCallAndDecode<'_, W, i64, impl EncodeArgs> {
self.caller.call_and_decode(
"nvim_buf_set_virtual_text",
(buffer, src_id, line, chunks, opts),
)
}
#[deprecated = "this method was deprecated since Neovim API level 9"]
#[inline]
pub fn get_hl_by_id(&self, hl_id: i64, rgb: bool) -> ApiCall<'_, W, impl EncodeArgs> {
self.caller.call("nvim_get_hl_by_id", (hl_id, rgb))
}
#[deprecated = "this method was deprecated since Neovim API level 9"]
#[inline]
pub fn get_hl_by_name(&self, name: &str, rgb: bool) -> ApiCall<'_, W, impl EncodeArgs> {
self.caller.call("nvim_get_hl_by_name", (name, rgb))
}
#[deprecated = "this method was deprecated since Neovim API level 11"]
#[inline]
pub fn get_option_info(&self, name: &str) -> ApiCall<'_, W, impl EncodeArgs> {
self.caller.call("nvim_get_option_info", name)
}
#[deprecated = "this method was deprecated since Neovim API level 11"]
#[inline]
pub fn set_option(
&self,
name: &str,
value: impl Encode,
) -> ApiCallAndDecode<'_, W, (), impl EncodeArgs> {
self.caller
.call_and_decode("nvim_set_option", (name, value))
}
#[deprecated = "this method was deprecated since Neovim API level 11"]
#[inline]
pub fn get_option(&self, name: &str) -> ApiCall<'_, W, impl EncodeArgs> {
self.caller.call("nvim_get_option", name)
}
#[deprecated = "this method was deprecated since Neovim API level 11"]
#[inline]
pub fn buf_get_option(&self, buffer: Buffer, name: &str) -> ApiCall<'_, W, impl EncodeArgs> {
self.caller.call("nvim_buf_get_option", (buffer, name))
}
#[deprecated = "this method was deprecated since Neovim API level 11"]
#[inline]
pub fn buf_set_option(
&self,
buffer: Buffer,
name: &str,
value: impl Encode,
) -> ApiCallAndDecode<'_, W, (), impl EncodeArgs> {
self.caller
.call_and_decode("nvim_buf_set_option", (buffer, name, value))
}
#[deprecated = "this method was deprecated since Neovim API level 11"]
#[inline]
pub fn win_get_option(&self, window: Window, name: &str) -> ApiCall<'_, W, impl EncodeArgs> {
self.caller.call("nvim_win_get_option", (window, name))
}
#[deprecated = "this method was deprecated since Neovim API level 11"]
#[inline]
pub fn win_set_option(
&self,
window: Window,
name: &str,
value: impl Encode,
) -> ApiCallAndDecode<'_, W, (), impl EncodeArgs> {
self.caller
.call_and_decode("nvim_win_set_option", (window, name, value))
}
#[deprecated = "this method was deprecated since Neovim API level 12"]
#[inline]
pub fn call_atomic(&self, calls: impl Encode) -> ApiCall<'_, W, impl EncodeArgs> {
self.caller.call("nvim_call_atomic", calls)
}
#[deprecated = "this method was deprecated since Neovim API level 13"]
#[inline]
pub fn subscribe(&self, event: &str) -> ApiCallAndDecode<'_, W, (), impl EncodeArgs> {
self.caller.call_and_decode("nvim_subscribe", event)
}
#[deprecated = "this method was deprecated since Neovim API level 13"]
#[inline]
pub fn unsubscribe(&self, event: &str) -> ApiCallAndDecode<'_, W, (), impl EncodeArgs> {
self.caller.call_and_decode("nvim_unsubscribe", event)
}
#[deprecated = "this method was deprecated since Neovim API level 13"]
#[inline]
pub fn out_write(&self, str: &str) -> ApiCallAndDecode<'_, W, (), impl EncodeArgs> {
self.caller.call_and_decode("nvim_out_write", str)
}
#[deprecated = "this method was deprecated since Neovim API level 13"]
#[inline]
pub fn err_write(&self, str: &str) -> ApiCallAndDecode<'_, W, (), impl EncodeArgs> {
self.caller.call_and_decode("nvim_err_write", str)
}
#[deprecated = "this method was deprecated since Neovim API level 13"]
#[inline]
pub fn err_writeln(&self, str: &str) -> ApiCallAndDecode<'_, W, (), impl EncodeArgs> {
self.caller.call_and_decode("nvim_err_writeln", str)
}
#[deprecated = "this method was deprecated since Neovim API level 13"]
#[inline]
pub fn notify(
&self,
msg: &str,
log_level: i64,
opts: impl Encode,
) -> ApiCall<'_, W, impl EncodeArgs> {
self.caller.call("nvim_notify", (msg, log_level, opts))
}
#[inline]
pub fn ui_term_event(
&self,
event: &str,
value: impl Encode,
) -> ApiCallAndDecode<'_, W, (), impl EncodeArgs> {
self.caller
.call_and_decode("nvim_ui_term_event", (event, value))
}
#[inline]
pub fn create_namespace(&self, name: &str) -> ApiCallAndDecode<'_, W, i64, impl EncodeArgs> {
self.caller.call_and_decode("nvim_create_namespace", name)
}
#[inline]
pub fn get_namespaces(&self) -> ApiCall<'_, W, impl EncodeArgs> {
self.caller.call("nvim_get_namespaces", ())
}
#[inline]
pub fn buf_get_extmark_by_id(
&self,
buf: Buffer,
ns_id: i64,
id: i64,
opts: impl Encode,
) -> ApiCall<'_, W, impl EncodeArgs> {
self.caller
.call("nvim_buf_get_extmark_by_id", (buf, ns_id, id, opts))
}
#[inline]
pub fn buf_get_extmarks(
&self,
buf: Buffer,
ns_id: i64,
start: impl Encode,
end: impl Encode,
opts: impl Encode,
) -> ApiCall<'_, W, impl EncodeArgs> {
self.caller
.call("nvim_buf_get_extmarks", (buf, ns_id, start, end, opts))
}
#[inline]
pub fn buf_set_extmark(
&self,
buf: Buffer,
ns_id: i64,
line: i64,
col: i64,
opts: impl Encode,
) -> ApiCallAndDecode<'_, W, i64, impl EncodeArgs> {
self.caller
.call_and_decode("nvim_buf_set_extmark", (buf, ns_id, line, col, opts))
}
#[inline]
pub fn buf_del_extmark(
&self,
buf: Buffer,
ns_id: i64,
id: i64,
) -> ApiCallAndDecode<'_, W, bool, impl EncodeArgs> {
self.caller
.call_and_decode("nvim_buf_del_extmark", (buf, ns_id, id))
}
#[inline]
pub fn buf_clear_namespace(
&self,
buf: Buffer,
ns_id: i64,
line_start: i64,
line_end: i64,
) -> ApiCallAndDecode<'_, W, (), impl EncodeArgs> {
self.caller.call_and_decode(
"nvim_buf_clear_namespace",
(buf, ns_id, line_start, line_end),
)
}
#[inline]
pub fn set_decoration_provider(
&self,
ns_id: i64,
opts: impl Encode,
) -> ApiCallAndDecode<'_, W, (), impl EncodeArgs> {
self.caller
.call_and_decode("nvim_set_decoration_provider", (ns_id, opts))
}
#[inline]
pub fn get_option_value(
&self,
name: &str,
opts: impl Encode,
) -> ApiCall<'_, W, impl EncodeArgs> {
self.caller.call("nvim_get_option_value", (name, opts))
}
#[inline]
pub fn set_option_value(
&self,
name: &str,
value: impl Encode,
opts: impl Encode,
) -> ApiCallAndDecode<'_, W, (), impl EncodeArgs> {
self.caller
.call_and_decode("nvim_set_option_value", (name, value, opts))
}
#[inline]
pub fn get_all_options_info(&self) -> ApiCall<'_, W, impl EncodeArgs> {
self.caller.call("nvim_get_all_options_info", ())
}
#[inline]
pub fn get_option_info2(
&self,
name: &str,
opts: impl Encode,
) -> ApiCall<'_, W, impl EncodeArgs> {
self.caller.call("nvim_get_option_info2", (name, opts))
}
#[inline]
pub fn tabpage_list_wins(&self, tabpage: Tabpage) -> ApiCall<'_, W, impl EncodeArgs> {
self.caller.call("nvim_tabpage_list_wins", tabpage)
}
#[inline]
pub fn tabpage_get_var(&self, tabpage: Tabpage, name: &str) -> ApiCall<'_, W, impl EncodeArgs> {
self.caller.call("nvim_tabpage_get_var", (tabpage, name))
}
#[inline]
pub fn tabpage_set_var(
&self,
tabpage: Tabpage,
name: &str,
value: impl Encode,
) -> ApiCallAndDecode<'_, W, (), impl EncodeArgs> {
self.caller
.call_and_decode("nvim_tabpage_set_var", (tabpage, name, value))
}
#[inline]
pub fn tabpage_del_var(
&self,
tabpage: Tabpage,
name: &str,
) -> ApiCallAndDecode<'_, W, (), impl EncodeArgs> {
self.caller
.call_and_decode("nvim_tabpage_del_var", (tabpage, name))
}
#[inline]
pub fn tabpage_get_win(
&self,
tabpage: Tabpage,
) -> ApiCallAndDecode<'_, W, Window, impl EncodeArgs> {
self.caller.call_and_decode("nvim_tabpage_get_win", tabpage)
}
#[inline]
pub fn tabpage_set_win(
&self,
tabpage: Tabpage,
win: Window,
) -> ApiCallAndDecode<'_, W, (), impl EncodeArgs> {
self.caller
.call_and_decode("nvim_tabpage_set_win", (tabpage, win))
}
#[inline]
pub fn tabpage_get_number(
&self,
tabpage: Tabpage,
) -> ApiCallAndDecode<'_, W, i64, impl EncodeArgs> {
self.caller
.call_and_decode("nvim_tabpage_get_number", tabpage)
}
#[inline]
pub fn tabpage_is_valid(
&self,
tabpage: Tabpage,
) -> ApiCallAndDecode<'_, W, bool, impl EncodeArgs> {
self.caller
.call_and_decode("nvim_tabpage_is_valid", tabpage)
}
#[inline]
pub fn open_tabpage(
&self,
buf: Buffer,
enter: bool,
config: impl Encode,
) -> ApiCallAndDecode<'_, W, Tabpage, impl EncodeArgs> {
self.caller
.call_and_decode("nvim_open_tabpage", (buf, enter, config))
}
#[inline]
pub fn ui_attach(
&self,
width: i64,
height: i64,
options: impl Encode,
) -> ApiCallAndDecode<'_, W, (), impl EncodeArgs> {
self.caller
.call_and_decode("nvim_ui_attach", (width, height, options))
}
#[inline]
pub fn ui_set_focus(&self, gained: bool) -> ApiCallAndDecode<'_, W, (), impl EncodeArgs> {
self.caller.call_and_decode("nvim_ui_set_focus", gained)
}
#[inline]
pub fn ui_detach(&self) -> ApiCallAndDecode<'_, W, (), impl EncodeArgs> {
self.caller.call_and_decode("nvim_ui_detach", ())
}
#[inline]
pub fn ui_try_resize(
&self,
width: i64,
height: i64,
) -> ApiCallAndDecode<'_, W, (), impl EncodeArgs> {
self.caller
.call_and_decode("nvim_ui_try_resize", (width, height))
}
#[inline]
pub fn ui_set_option(
&self,
name: &str,
value: impl Encode,
) -> ApiCallAndDecode<'_, W, (), impl EncodeArgs> {
self.caller
.call_and_decode("nvim_ui_set_option", (name, value))
}
#[inline]
pub fn ui_try_resize_grid(
&self,
grid: i64,
width: i64,
height: i64,
) -> ApiCallAndDecode<'_, W, (), impl EncodeArgs> {
self.caller
.call_and_decode("nvim_ui_try_resize_grid", (grid, width, height))
}
#[inline]
pub fn ui_pum_set_height(&self, height: i64) -> ApiCallAndDecode<'_, W, (), impl EncodeArgs> {
self.caller
.call_and_decode("nvim_ui_pum_set_height", height)
}
#[inline]
pub fn ui_pum_set_bounds(
&self,
width: impl Encode,
height: impl Encode,
row: impl Encode,
col: impl Encode,
) -> ApiCallAndDecode<'_, W, (), impl EncodeArgs> {
self.caller
.call_and_decode("nvim_ui_pum_set_bounds", (width, height, row, col))
}
#[inline]
pub fn ui_send(&self, content: &str) -> ApiCallAndDecode<'_, W, (), impl EncodeArgs> {
self.caller.call_and_decode("nvim_ui_send", content)
}
#[inline]
pub fn get_hl_id_by_name(&self, name: &str) -> ApiCallAndDecode<'_, W, i64, impl EncodeArgs> {
self.caller.call_and_decode("nvim_get_hl_id_by_name", name)
}
#[inline]
pub fn get_hl(&self, ns_id: i64, opts: impl Encode) -> ApiCall<'_, W, impl EncodeArgs> {
self.caller.call("nvim_get_hl", (ns_id, opts))
}
#[inline]
pub fn set_hl(
&self,
ns_id: i64,
name: &str,
val: impl Encode,
) -> ApiCallAndDecode<'_, W, (), impl EncodeArgs> {
self.caller
.call_and_decode("nvim_set_hl", (ns_id, name, val))
}
#[inline]
pub fn get_hl_ns(&self, opts: impl Encode) -> ApiCallAndDecode<'_, W, i64, impl EncodeArgs> {
self.caller.call_and_decode("nvim_get_hl_ns", opts)
}
#[inline]
pub fn set_hl_ns(&self, ns_id: i64) -> ApiCallAndDecode<'_, W, (), impl EncodeArgs> {
self.caller.call_and_decode("nvim_set_hl_ns", ns_id)
}
#[inline]
pub fn set_hl_ns_fast(&self, ns_id: i64) -> ApiCallAndDecode<'_, W, (), impl EncodeArgs> {
self.caller.call_and_decode("nvim_set_hl_ns_fast", ns_id)
}
#[inline]
pub fn feedkeys(
&self,
keys: &str,
mode: &str,
escape_ks: bool,
) -> ApiCallAndDecode<'_, W, (), impl EncodeArgs> {
self.caller
.call_and_decode("nvim_feedkeys", (keys, mode, escape_ks))
}
#[inline]
pub fn input(&self, keys: &str) -> ApiCallAndDecode<'_, W, i64, impl EncodeArgs> {
self.caller.call_and_decode("nvim_input", keys)
}
#[inline]
pub fn input_mouse(
&self,
button: &str,
action: &str,
modifier: &str,
grid: i64,
row: i64,
col: i64,
) -> ApiCallAndDecode<'_, W, (), impl EncodeArgs> {
self.caller.call_and_decode(
"nvim_input_mouse",
(button, action, modifier, grid, row, col),
)
}
#[inline]
pub fn replace_termcodes(
&self,
str: &str,
from_part: bool,
do_lt: bool,
special: bool,
) -> ApiCall<'_, W, impl EncodeArgs> {
self.caller
.call("nvim_replace_termcodes", (str, from_part, do_lt, special))
}
#[inline]
pub fn exec_lua(&self, code: &str, args: impl Encode) -> ApiCall<'_, W, impl EncodeArgs> {
self.caller.call("nvim_exec_lua", (code, args))
}
#[inline]
pub fn strwidth(&self, text: &str) -> ApiCallAndDecode<'_, W, i64, impl EncodeArgs> {
self.caller.call_and_decode("nvim_strwidth", text)
}
#[inline]
pub fn list_runtime_paths(&self) -> ApiCall<'_, W, impl EncodeArgs> {
self.caller.call("nvim_list_runtime_paths", ())
}
#[inline]
pub fn get_runtime_file(&self, name: &str, all: bool) -> ApiCall<'_, W, impl EncodeArgs> {
self.caller.call("nvim_get_runtime_file", (name, all))
}
#[inline]
pub fn set_current_dir(&self, dir: &str) -> ApiCallAndDecode<'_, W, (), impl EncodeArgs> {
self.caller.call_and_decode("nvim_set_current_dir", dir)
}
#[inline]
pub fn get_current_line(&self) -> ApiCall<'_, W, impl EncodeArgs> {
self.caller.call("nvim_get_current_line", ())
}
#[inline]
pub fn set_current_line(&self, line: &str) -> ApiCallAndDecode<'_, W, (), impl EncodeArgs> {
self.caller.call_and_decode("nvim_set_current_line", line)
}
#[inline]
pub fn del_current_line(&self) -> ApiCallAndDecode<'_, W, (), impl EncodeArgs> {
self.caller.call_and_decode("nvim_del_current_line", ())
}
#[inline]
pub fn get_var(&self, name: &str) -> ApiCall<'_, W, impl EncodeArgs> {
self.caller.call("nvim_get_var", name)
}
#[inline]
pub fn set_var(
&self,
name: &str,
value: impl Encode,
) -> ApiCallAndDecode<'_, W, (), impl EncodeArgs> {
self.caller.call_and_decode("nvim_set_var", (name, value))
}
#[inline]
pub fn del_var(&self, name: &str) -> ApiCallAndDecode<'_, W, (), impl EncodeArgs> {
self.caller.call_and_decode("nvim_del_var", name)
}
#[inline]
pub fn get_vvar(&self, name: &str) -> ApiCall<'_, W, impl EncodeArgs> {
self.caller.call("nvim_get_vvar", name)
}
#[inline]
pub fn set_vvar(
&self,
name: &str,
value: impl Encode,
) -> ApiCallAndDecode<'_, W, (), impl EncodeArgs> {
self.caller.call_and_decode("nvim_set_vvar", (name, value))
}
#[inline]
pub fn echo(
&self,
chunks: impl Encode,
history: bool,
opts: impl Encode,
) -> ApiCall<'_, W, impl EncodeArgs> {
self.caller.call("nvim_echo", (chunks, history, opts))
}
#[inline]
pub fn list_bufs(&self) -> ApiCall<'_, W, impl EncodeArgs> {
self.caller.call("nvim_list_bufs", ())
}
#[inline]
pub fn get_current_buf(&self) -> ApiCallAndDecode<'_, W, Buffer, impl EncodeArgs> {
self.caller.call_and_decode("nvim_get_current_buf", ())
}
#[inline]
pub fn set_current_buf(&self, buf: Buffer) -> ApiCallAndDecode<'_, W, (), impl EncodeArgs> {
self.caller.call_and_decode("nvim_set_current_buf", buf)
}
#[inline]
pub fn list_wins(&self) -> ApiCall<'_, W, impl EncodeArgs> {
self.caller.call("nvim_list_wins", ())
}
#[inline]
pub fn get_current_win(&self) -> ApiCallAndDecode<'_, W, Window, impl EncodeArgs> {
self.caller.call_and_decode("nvim_get_current_win", ())
}
#[inline]
pub fn set_current_win(&self, win: Window) -> ApiCallAndDecode<'_, W, (), impl EncodeArgs> {
self.caller.call_and_decode("nvim_set_current_win", win)
}
#[inline]
pub fn create_buf(
&self,
listed: bool,
scratch: bool,
) -> ApiCallAndDecode<'_, W, Buffer, impl EncodeArgs> {
self.caller
.call_and_decode("nvim_create_buf", (listed, scratch))
}
#[inline]
pub fn open_term(
&self,
buf: Buffer,
opts: impl Encode,
) -> ApiCallAndDecode<'_, W, i64, impl EncodeArgs> {
self.caller.call_and_decode("nvim_open_term", (buf, opts))
}
#[inline]
pub fn chan_send(&self, chan: i64, data: &str) -> ApiCallAndDecode<'_, W, (), impl EncodeArgs> {
self.caller.call_and_decode("nvim_chan_send", (chan, data))
}
#[inline]
pub fn list_tabpages(&self) -> ApiCall<'_, W, impl EncodeArgs> {
self.caller.call("nvim_list_tabpages", ())
}
#[inline]
pub fn get_current_tabpage(&self) -> ApiCallAndDecode<'_, W, Tabpage, impl EncodeArgs> {
self.caller.call_and_decode("nvim_get_current_tabpage", ())
}
#[inline]
pub fn set_current_tabpage(
&self,
tabpage: Tabpage,
) -> ApiCallAndDecode<'_, W, (), impl EncodeArgs> {
self.caller
.call_and_decode("nvim_set_current_tabpage", tabpage)
}
#[inline]
pub fn paste(
&self,
data: &str,
crlf: bool,
phase: i64,
) -> ApiCallAndDecode<'_, W, bool, impl EncodeArgs> {
self.caller
.call_and_decode("nvim_paste", (data, crlf, phase))
}
#[inline]
pub fn put(
&self,
lines: impl Encode,
r#type: &str,
after: bool,
follow: bool,
) -> ApiCallAndDecode<'_, W, (), impl EncodeArgs> {
self.caller
.call_and_decode("nvim_put", (lines, r#type, after, follow))
}
#[inline]
pub fn get_color_by_name(&self, name: &str) -> ApiCallAndDecode<'_, W, i64, impl EncodeArgs> {
self.caller.call_and_decode("nvim_get_color_by_name", name)
}
#[inline]
pub fn get_color_map(&self) -> ApiCall<'_, W, impl EncodeArgs> {
self.caller.call("nvim_get_color_map", ())
}
#[inline]
pub fn get_context(&self, opts: impl Encode) -> ApiCall<'_, W, impl EncodeArgs> {
self.caller.call("nvim_get_context", opts)
}
#[inline]
pub fn load_context(&self, dict: impl Encode) -> ApiCall<'_, W, impl EncodeArgs> {
self.caller.call("nvim_load_context", dict)
}
#[inline]
pub fn get_mode(&self) -> ApiCall<'_, W, impl EncodeArgs> {
self.caller.call("nvim_get_mode", ())
}
#[inline]
pub fn get_keymap(&self, mode: &str) -> ApiCall<'_, W, impl EncodeArgs> {
self.caller.call("nvim_get_keymap", mode)
}
#[inline]
pub fn set_keymap(
&self,
mode: &str,
lhs: &str,
rhs: &str,
opts: impl Encode,
) -> ApiCallAndDecode<'_, W, (), impl EncodeArgs> {
self.caller
.call_and_decode("nvim_set_keymap", (mode, lhs, rhs, opts))
}
#[inline]
pub fn del_keymap(
&self,
mode: &str,
lhs: &str,
) -> ApiCallAndDecode<'_, W, (), impl EncodeArgs> {
self.caller.call_and_decode("nvim_del_keymap", (mode, lhs))
}
#[inline]
pub fn get_api_info(&self) -> ApiCall<'_, W, impl EncodeArgs> {
self.caller.call("nvim_get_api_info", ())
}
#[inline]
pub fn set_client_info(
&self,
name: &str,
version: impl Encode,
r#type: &str,
methods: impl Encode,
attributes: impl Encode,
) -> ApiCallAndDecode<'_, W, (), impl EncodeArgs> {
self.caller.call_and_decode(
"nvim_set_client_info",
(name, version, r#type, methods, attributes),
)
}
#[inline]
pub fn get_chan_info(&self, chan: i64) -> ApiCall<'_, W, impl EncodeArgs> {
self.caller.call("nvim_get_chan_info", chan)
}
#[inline]
pub fn list_chans(&self) -> ApiCall<'_, W, impl EncodeArgs> {
self.caller.call("nvim_list_chans", ())
}
#[inline]
pub fn list_uis(&self) -> ApiCall<'_, W, impl EncodeArgs> {
self.caller.call("nvim_list_uis", ())
}
#[inline]
pub fn get_proc_children(&self, pid: i64) -> ApiCall<'_, W, impl EncodeArgs> {
self.caller.call("nvim_get_proc_children", pid)
}
#[inline]
pub fn get_proc(&self, pid: i64) -> ApiCall<'_, W, impl EncodeArgs> {
self.caller.call("nvim_get_proc", pid)
}
#[inline]
pub fn select_popupmenu_item(
&self,
item: i64,
insert: bool,
finish: bool,
opts: impl Encode,
) -> ApiCallAndDecode<'_, W, (), impl EncodeArgs> {
self.caller
.call_and_decode("nvim_select_popupmenu_item", (item, insert, finish, opts))
}
#[inline]
pub fn del_mark(&self, name: &str) -> ApiCallAndDecode<'_, W, bool, impl EncodeArgs> {
self.caller.call_and_decode("nvim_del_mark", name)
}
#[inline]
pub fn get_mark(&self, name: &str, opts: impl Encode) -> ApiCall<'_, W, impl EncodeArgs> {
self.caller.call("nvim_get_mark", (name, opts))
}
#[inline]
pub fn eval_statusline(&self, str: &str, opts: impl Encode) -> ApiCall<'_, W, impl EncodeArgs> {
self.caller.call("nvim_eval_statusline", (str, opts))
}
#[inline]
pub fn exec2(&self, src: &str, opts: impl Encode) -> ApiCall<'_, W, impl EncodeArgs> {
self.caller.call("nvim_exec2", (src, opts))
}
#[inline]
pub fn command(&self, cmd: &str) -> ApiCallAndDecode<'_, W, (), impl EncodeArgs> {
self.caller.call_and_decode("nvim_command", cmd)
}
#[inline]
pub fn eval(&self, expr: &str) -> ApiCall<'_, W, impl EncodeArgs> {
self.caller.call("nvim_eval", expr)
}
#[inline]
pub fn call_function(&self, r#fn: &str, args: impl Encode) -> ApiCall<'_, W, impl EncodeArgs> {
self.caller.call("nvim_call_function", (r#fn, args))
}
#[inline]
pub fn call_dict_function(
&self,
dict: impl Encode,
r#fn: &str,
args: impl Encode,
) -> ApiCall<'_, W, impl EncodeArgs> {
self.caller
.call("nvim_call_dict_function", (dict, r#fn, args))
}
#[inline]
pub fn parse_expression(
&self,
expr: &str,
flags: &str,
hl: bool,
) -> ApiCall<'_, W, impl EncodeArgs> {
self.caller.call("nvim_parse_expression", (expr, flags, hl))
}
#[inline]
pub fn open_win(
&self,
buf: Buffer,
enter: bool,
config: impl Encode,
) -> ApiCallAndDecode<'_, W, Window, impl EncodeArgs> {
self.caller
.call_and_decode("nvim_open_win", (buf, enter, config))
}
#[inline]
pub fn win_set_config(
&self,
win: Window,
config: impl Encode,
) -> ApiCallAndDecode<'_, W, (), impl EncodeArgs> {
self.caller
.call_and_decode("nvim_win_set_config", (win, config))
}
#[inline]
pub fn win_get_config(&self, win: Window) -> ApiCall<'_, W, impl EncodeArgs> {
self.caller.call("nvim_win_get_config", win)
}
#[inline]
pub fn win_get_buf(&self, win: Window) -> ApiCallAndDecode<'_, W, Buffer, impl EncodeArgs> {
self.caller.call_and_decode("nvim_win_get_buf", win)
}
#[inline]
pub fn win_set_buf(
&self,
win: Window,
buf: Buffer,
) -> ApiCallAndDecode<'_, W, (), impl EncodeArgs> {
self.caller.call_and_decode("nvim_win_set_buf", (win, buf))
}
#[inline]
pub fn win_get_cursor(&self, win: Window) -> ApiCall<'_, W, impl EncodeArgs> {
self.caller.call("nvim_win_get_cursor", win)
}
#[inline]
pub fn win_set_cursor(
&self,
win: Window,
pos: impl Encode,
) -> ApiCallAndDecode<'_, W, (), impl EncodeArgs> {
self.caller
.call_and_decode("nvim_win_set_cursor", (win, pos))
}
#[inline]
pub fn win_get_height(&self, win: Window) -> ApiCallAndDecode<'_, W, i64, impl EncodeArgs> {
self.caller.call_and_decode("nvim_win_get_height", win)
}
#[inline]
pub fn win_set_height(
&self,
win: Window,
height: i64,
) -> ApiCallAndDecode<'_, W, (), impl EncodeArgs> {
self.caller
.call_and_decode("nvim_win_set_height", (win, height))
}
#[inline]
pub fn win_get_width(&self, win: Window) -> ApiCallAndDecode<'_, W, i64, impl EncodeArgs> {
self.caller.call_and_decode("nvim_win_get_width", win)
}
#[inline]
pub fn win_set_width(
&self,
win: Window,
width: i64,
) -> ApiCallAndDecode<'_, W, (), impl EncodeArgs> {
self.caller
.call_and_decode("nvim_win_set_width", (win, width))
}
#[inline]
pub fn win_get_var(&self, win: Window, name: &str) -> ApiCall<'_, W, impl EncodeArgs> {
self.caller.call("nvim_win_get_var", (win, name))
}
#[inline]
pub fn win_set_var(
&self,
win: Window,
name: &str,
value: impl Encode,
) -> ApiCallAndDecode<'_, W, (), impl EncodeArgs> {
self.caller
.call_and_decode("nvim_win_set_var", (win, name, value))
}
#[inline]
pub fn win_del_var(
&self,
win: Window,
name: &str,
) -> ApiCallAndDecode<'_, W, (), impl EncodeArgs> {
self.caller.call_and_decode("nvim_win_del_var", (win, name))
}
#[inline]
pub fn win_get_position(&self, win: Window) -> ApiCall<'_, W, impl EncodeArgs> {
self.caller.call("nvim_win_get_position", win)
}
#[inline]
pub fn win_get_tabpage(
&self,
win: Window,
) -> ApiCallAndDecode<'_, W, Tabpage, impl EncodeArgs> {
self.caller.call_and_decode("nvim_win_get_tabpage", win)
}
#[inline]
pub fn win_get_number(&self, win: Window) -> ApiCallAndDecode<'_, W, i64, impl EncodeArgs> {
self.caller.call_and_decode("nvim_win_get_number", win)
}
#[inline]
pub fn win_is_valid(&self, win: Window) -> ApiCallAndDecode<'_, W, bool, impl EncodeArgs> {
self.caller.call_and_decode("nvim_win_is_valid", win)
}
#[inline]
pub fn win_hide(&self, win: Window) -> ApiCallAndDecode<'_, W, (), impl EncodeArgs> {
self.caller.call_and_decode("nvim_win_hide", win)
}
#[inline]
pub fn win_close(
&self,
win: Window,
force: bool,
) -> ApiCallAndDecode<'_, W, (), impl EncodeArgs> {
self.caller.call_and_decode("nvim_win_close", (win, force))
}
#[inline]
pub fn win_call(&self, win: Window, fun: impl Encode) -> ApiCall<'_, W, impl EncodeArgs> {
self.caller.call("nvim_win_call", (win, fun))
}
#[inline]
pub fn win_set_hl_ns(
&self,
win: Window,
ns_id: i64,
) -> ApiCallAndDecode<'_, W, (), impl EncodeArgs> {
self.caller
.call_and_decode("nvim_win_set_hl_ns", (win, ns_id))
}
#[inline]
pub fn win_text_height(
&self,
win: Window,
opts: impl Encode,
) -> ApiCall<'_, W, impl EncodeArgs> {
self.caller.call("nvim_win_text_height", (win, opts))
}
}