pub struct Buffer(_);Expand description
A wrapper around a Neovim buffer handle.
Implementations
sourceimpl Buffer
impl Buffer
sourcepub fn current() -> Buffer
pub fn current() -> Buffer
Shorthand for get_current_buf.
sourcepub fn attach(&self, send_buffer: bool, opts: &BufAttachOpts) -> Result<(), Error>
pub fn attach(&self, send_buffer: bool, opts: &BufAttachOpts) -> Result<(), Error>
Binding to nvim_buf_attach.
Used to register a set of callbacks on specific buffer events.
sourcepub fn call<F, R>(&self, fun: F) -> Result<R, Error>where
F: 'static + FnOnce(()) -> Result<R, Error>,
R: Pushable + FromObject,
pub fn call<F, R>(&self, fun: F) -> Result<R, Error>where
F: 'static + FnOnce(()) -> Result<R, Error>,
R: Pushable + FromObject,
Binding to nvim_buf_call.
Calls a function with this buffer as the temporary current buffer.
sourcepub fn create_user_command<Cmd>(
&mut self,
name: &str,
command: Cmd,
opts: &CreateCommandOpts
) -> Result<(), Error>where
Cmd: StringOrFunction<CommandArgs, ()>,
pub fn create_user_command<Cmd>(
&mut self,
name: &str,
command: Cmd,
opts: &CreateCommandOpts
) -> Result<(), Error>where
Cmd: StringOrFunction<CommandArgs, ()>,
Binding to nvim_buf_create_user_command.
Creates a new buffer-local user command.
sourcepub fn del_keymap(&mut self, mode: Mode, lhs: &str) -> Result<(), Error>
pub fn del_keymap(&mut self, mode: Mode, lhs: &str) -> Result<(), Error>
Binding to nvim_buf_del_keymap.
Unmaps a buffer-local mapping for the given mode.
sourcepub fn del_mark(&mut self, name: char) -> Result<(), Error>
pub fn del_mark(&mut self, name: char) -> Result<(), Error>
Binding to nvim_buf_del_mark.
Deletes a named mark in the buffer.
sourcepub fn del_user_command(&mut self, name: &str) -> Result<(), Error>
pub fn del_user_command(&mut self, name: &str) -> Result<(), Error>
Binding to nvim_buf_del_user_command.
Deletes a buffer-local user-command. Use
del_user_command to delete a global
command.
sourcepub fn del_var(&mut self, name: &str) -> Result<(), Error>
pub fn del_var(&mut self, name: &str) -> Result<(), Error>
Binding to nvim_buf_del_var.
Removes a buffer-scoped (b:) variable.
sourcepub fn delete(self, opts: &BufDeleteOpts) -> Result<(), Error>
pub fn delete(self, opts: &BufDeleteOpts) -> Result<(), Error>
Binding to nvim_buf_delete.
Deletes the buffer (not allowed while
textlock is active).
sourcepub fn get_changedtick(&self) -> Result<u32, Error>
pub fn get_changedtick(&self) -> Result<u32, Error>
Binding to nvim_buf_get_changedtick.
sourcepub fn get_commands(
&self,
opts: &GetCommandsOpts
) -> Result<impl SuperIterator<CommandInfos>, Error>
pub fn get_commands(
&self,
opts: &GetCommandsOpts
) -> Result<impl SuperIterator<CommandInfos>, Error>
Binding to nvim_buf_get_commands.
sourcepub fn get_keymap(
&self,
mode: Mode
) -> Result<impl SuperIterator<KeymapInfos>, Error>
pub fn get_keymap(
&self,
mode: Mode
) -> Result<impl SuperIterator<KeymapInfos>, Error>
Binding to nvim_buf_get_keymap.
sourcepub fn get_lines<R>(
&self,
line_range: R,
strict_indexing: bool
) -> Result<impl SuperIterator<String>, Error>where
R: RangeBounds<usize>,
pub fn get_lines<R>(
&self,
line_range: R,
strict_indexing: bool
) -> Result<impl SuperIterator<String>, Error>where
R: RangeBounds<usize>,
Binding to nvim_buf_get_lines.
Gets a line range from the buffer. Indexing is zero-based, end-exclusive.
sourcepub fn get_mark(&self, name: char) -> Result<(usize, usize), Error>
pub fn get_mark(&self, name: char) -> Result<(usize, usize), Error>
Binding to nvim_buf_get_mark.
Returns a (1-0) indexed (row, col) tuple representing the position
of the named mark.
sourcepub fn get_name(&self) -> Result<PathBuf, Error>
pub fn get_name(&self) -> Result<PathBuf, Error>
Binding to nvim_buf_get_name.
Returns the full filepath of the buffer.
sourcepub fn get_offset(&self, index: usize) -> Result<usize, Error>
pub fn get_offset(&self, index: usize) -> Result<usize, Error>
Binding to nvim_buf_get_offset.
Returns the 0-indexed byte offset of a line.
sourcepub fn get_option<Opt>(&self, name: &str) -> Result<Opt, Error>where
Opt: FromObject,
pub fn get_option<Opt>(&self, name: &str) -> Result<Opt, Error>where
Opt: FromObject,
Binding to nvim_buf_get_option.
Gets a buffer option value.
sourcepub fn get_text<R>(
&self,
line_range: R,
start_col: usize,
end_col: usize,
opts: &GetTextOpts
) -> Result<impl SuperIterator<String>, Error>where
R: RangeBounds<usize>,
pub fn get_text<R>(
&self,
line_range: R,
start_col: usize,
end_col: usize,
opts: &GetTextOpts
) -> Result<impl SuperIterator<String>, Error>where
R: RangeBounds<usize>,
Binding to nvim_buf_get_text.
Gets a range from the buffer. This differs from Buffer::get_lines in
that it allows retrieving only portions of a line.
Indexing is zero-based, with both row and column indices being end-exclusive.
sourcepub fn get_var<Var>(&self, name: &str) -> Result<Var, Error>where
Var: FromObject,
pub fn get_var<Var>(&self, name: &str) -> Result<Var, Error>where
Var: FromObject,
Binding to nvim_buf_get_var.
Gets a buffer-scoped (b:) variable.
sourcepub fn is_loaded(&self) -> bool
pub fn is_loaded(&self) -> bool
Binding to nvim_buf_is_loaded.
Checks if a buffer is valid and loaded.
sourcepub fn is_valid(&self) -> bool
pub fn is_valid(&self) -> bool
Binding to nvim_buf_is_valid.
Checks if a buffer is valid.
sourcepub fn line_count(&self) -> Result<usize, Error>
pub fn line_count(&self) -> Result<usize, Error>
Binding to nvim_buf_line_count.
Returns the number of lines in the given buffer.
sourcepub fn set_keymap(
&mut self,
mode: Mode,
lhs: &str,
rhs: &str,
opts: &SetKeymapOpts
) -> Result<(), Error>
pub fn set_keymap(
&mut self,
mode: Mode,
lhs: &str,
rhs: &str,
opts: &SetKeymapOpts
) -> Result<(), Error>
Binding to nvim_buf_set_keymap.
Sets a buffer-local mapping for the given mode. To set a global mapping
use set_keymap instead.
sourcepub fn set_lines<Line, Lines, R>(
&mut self,
line_range: R,
strict_indexing: bool,
replacement: Lines
) -> Result<(), Error>where
R: RangeBounds<usize>,
Lines: IntoIterator<Item = Line>,
Line: Into<String>,
pub fn set_lines<Line, Lines, R>(
&mut self,
line_range: R,
strict_indexing: bool,
replacement: Lines
) -> Result<(), Error>where
R: RangeBounds<usize>,
Lines: IntoIterator<Item = Line>,
Line: Into<String>,
Binding to nvim_buf_set_lines.
Sets (replaces) a line-range in the buffer. Indexing is zero-based, end-exclusive.
sourcepub fn set_mark(
&mut self,
name: char,
line: usize,
col: usize
) -> Result<(), Error>
pub fn set_mark(
&mut self,
name: char,
line: usize,
col: usize
) -> Result<(), Error>
Binding to nvim_buf_set_mark.
Sets a named mark in the buffer. Marks are (1,0)-indexed, and passing 0
as line deletes the mark.
sourcepub fn set_name<Name>(&mut self, name: Name) -> Result<(), Error>where
Name: AsRef<Path>,
pub fn set_name<Name>(&mut self, name: Name) -> Result<(), Error>where
Name: AsRef<Path>,
Binding to nvim_buf_set_name.
Sets the full file name for a buffer.
sourcepub fn set_option<V>(&mut self, name: &str, value: V) -> Result<(), Error>where
V: ToObject,
pub fn set_option<V>(&mut self, name: &str, value: V) -> Result<(), Error>where
V: ToObject,
Binding to nvim_buf_set_option.
Sets a buffer option value. Passing None as value deletes the option
(only works if there’s a global fallback).
sourcepub fn set_text<Line, Lines, R>(
&mut self,
line_range: R,
start_col: usize,
end_col: usize,
replacement: Lines
) -> Result<(), Error>where
R: RangeBounds<usize>,
Lines: IntoIterator<Item = Line>,
Line: Into<String>,
pub fn set_text<Line, Lines, R>(
&mut self,
line_range: R,
start_col: usize,
end_col: usize,
replacement: Lines
) -> Result<(), Error>where
R: RangeBounds<usize>,
Lines: IntoIterator<Item = Line>,
Line: Into<String>,
Binding to nvim_buf_set_text.
Sets (replaces) a range in the buffer. Indexing is zero-based, with both row and column indices being end-exclusive.
sourceimpl Buffer
impl Buffer
sourcepub fn add_highlight<R>(
&mut self,
ns_id: u32,
hl_group: &str,
line: usize,
byte_range: R
) -> Result<i64, Error>where
R: RangeBounds<usize>,
pub fn add_highlight<R>(
&mut self,
ns_id: u32,
hl_group: &str,
line: usize,
byte_range: R
) -> Result<i64, Error>where
R: RangeBounds<usize>,
Binding to nvim_buf_add_highlight.
Adds a highlight to the buffer. Both line and byte_range are
0-indexed.
sourcepub fn clear_namespace<R>(
&mut self,
ns_id: u32,
line_range: R
) -> Result<(), Error>where
R: RangeBounds<usize>,
pub fn clear_namespace<R>(
&mut self,
ns_id: u32,
line_range: R
) -> Result<(), Error>where
R: RangeBounds<usize>,
Binding to nvim_buf_clear_namespace.
Clears namespaced objects like highlights, extmarks, or virtual text from a region.
The line range is 0-indexed.
sourcepub fn del_extmark(&mut self, ns_id: u32, extmark_id: u32) -> Result<(), Error>
pub fn del_extmark(&mut self, ns_id: u32, extmark_id: u32) -> Result<(), Error>
Binding to nvim_buf_del_extmark.
Removes an extmark from the buffer.
sourcepub fn get_extmark_by_id(
&self,
ns_id: u32,
extmark_id: u32,
opts: &GetExtmarkByIdOpts
) -> Result<(usize, usize, Option<ExtmarkInfos>), Error>
pub fn get_extmark_by_id(
&self,
ns_id: u32,
extmark_id: u32,
opts: &GetExtmarkByIdOpts
) -> Result<(usize, usize, Option<ExtmarkInfos>), Error>
Binding to nvim_buf_get_extmark_by_id.
The first two elements of the returned tuple represent the 0-indexed
row, col position of the extmark. The last element is only present if
the details option
field was set to true.
sourcepub fn get_extmarks(
&self,
ns_id: u32,
start: ExtmarkPosition,
end: ExtmarkPosition,
opts: &GetExtmarksOpts
) -> Result<impl SuperIterator<(u32, usize, usize, Option<ExtmarkInfos>)>, Error>
pub fn get_extmarks(
&self,
ns_id: u32,
start: ExtmarkPosition,
end: ExtmarkPosition,
opts: &GetExtmarksOpts
) -> Result<impl SuperIterator<(u32, usize, usize, Option<ExtmarkInfos>)>, Error>
Bindings to nvim_buf_get_extmarks.
Gets all the extmarks in a buffer region specified by start and end
positions. Returns an iterator over (extmark_id, row, col, infos)
tuples in “traversal order”. Like for Buffer::get_extmark_by_id,
the infos are present only if the
details option field
was set to true.
sourcepub fn set_extmark(
&mut self,
ns_id: u32,
line: usize,
col: usize,
opts: &SetExtmarkOpts
) -> Result<u32, Error>
pub fn set_extmark(
&mut self,
ns_id: u32,
line: usize,
col: usize,
opts: &SetExtmarkOpts
) -> Result<u32, Error>
Binding to nvim_buf_set_extmark.
Creates or updates an extmark. Both line and col are 0-indexed.
Returns the id of the created/updated extmark.