pub struct Buffer(/* private fields */);
Expand description
A wrapper around a Neovim buffer handle.
Implementations§
Source§impl Buffer
impl Buffer
Sourcepub fn current() -> Self
pub fn current() -> Self
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, Res, Ret>(&self, fun: F) -> Result<Ret, Error>where
F: FnOnce(()) -> Res + 'static,
Res: IntoResult<Ret>,
Res::Error: StdError + 'static,
Ret: Pushable + FromObject,
pub fn call<F, Res, Ret>(&self, fun: F) -> Result<Ret, Error>where
F: FnOnce(()) -> Res + 'static,
Res: IntoResult<Ret>,
Res::Error: StdError + 'static,
Ret: Pushable + FromObject,
Binding to nvim_buf_call()
.
Calls a function with this buffer as the temporary current buffer.
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_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_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_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>
pub fn set_lines<Line, Lines, R>( &mut self, line_range: R, strict_indexing: bool, replacement: Lines, ) -> Result<(), Error>
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,
opts: &SetMarkOpts,
) -> Result<(), Error>
pub fn set_mark( &mut self, name: char, line: usize, col: usize, opts: &SetMarkOpts, ) -> 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: AsRef<Path>>(&mut self, name: Name) -> Result<(), Error>
pub fn set_name<Name: AsRef<Path>>(&mut self, name: Name) -> Result<(), Error>
Binding to nvim_buf_set_name()
.
Sets the full file name for a buffer.
Source§impl Buffer
impl Buffer
Sourcepub fn create_user_command<Cmd>(
&mut self,
name: &str,
command: Cmd,
opts: &CreateCommandOpts,
) -> Result<(), Error>
pub fn create_user_command<Cmd>( &mut self, name: &str, command: Cmd, opts: &CreateCommandOpts, ) -> Result<(), Error>
Binding to nvim_buf_create_user_command()
.
Creates a new buffer-local user command.
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 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()
.
Source§impl Buffer
impl Buffer
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 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).
Source§impl 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.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Buffer
impl<'de> Deserialize<'de> for Buffer
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl FromObject for Buffer
impl FromObject for Buffer
impl Eq for Buffer
impl StructuralPartialEq for Buffer
Auto Trait Implementations§
impl Freeze for Buffer
impl RefUnwindSafe for Buffer
impl Send for Buffer
impl Sync for Buffer
impl Unpin for Buffer
impl UnwindSafe for Buffer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoResult<T> for T
impl<T> IntoResult<T> for T
Source§type Error = Infallible
type Error = Infallible
Result
.Source§fn into_result(self) -> Result<T, <T as IntoResult<T>>::Error>
fn into_result(self) -> Result<T, <T as IntoResult<T>>::Error>
Result
.