Struct Buffer
pub struct Buffer(pub(crate) i32);Expand description
A wrapper around a Neovim buffer handle.
Tuple Fields§
§0: i32Implementations§
§impl Buffer
impl Buffer
pub fn current() -> Buffer
pub fn current() -> Buffer
Shorthand for get_current_buf.
pub 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.
pub fn call<F, Res, Ret>(&self, fun: F) -> Result<Ret, Error>where
F: FnOnce(()) -> Res + 'static,
Res: IntoResult<Ret>,
<Res as IntoResult<Ret>>::Error: Error + '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 as IntoResult<Ret>>::Error: Error + 'static,
Ret: Pushable + FromObject,
Binding to nvim_buf_call().
Calls a function with this buffer as the temporary current buffer.
pub 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.
pub 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.
pub 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.
pub 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).
pub fn get_changedtick(&self) -> Result<u32, Error>
pub fn get_changedtick(&self) -> Result<u32, Error>
Binding to nvim_buf_get_changedtick().
pub fn get_keymap(
&self,
mode: Mode,
) -> Result<impl SuperIterator<KeymapInfos> + use<>, Error>
pub fn get_keymap( &self, mode: Mode, ) -> Result<impl SuperIterator<KeymapInfos> + use<>, Error>
Binding to nvim_buf_get_keymap().
pub fn get_lines<R>(
&self,
line_range: R,
strict_indexing: bool,
) -> Result<impl SuperIterator<String> + use<R>, Error>where
R: RangeBounds<usize>,
pub fn get_lines<R>(
&self,
line_range: R,
strict_indexing: bool,
) -> Result<impl SuperIterator<String> + use<R>, Error>where
R: RangeBounds<usize>,
Binding to nvim_buf_get_lines().
Gets a line range from the buffer. Indexing is zero-based, end-exclusive.
pub 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.
pub fn get_name(&self) -> Result<String, Error>
pub fn get_name(&self) -> Result<String, Error>
Binding to nvim_buf_get_name().
Returns the full filepath of the buffer.
pub 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.
pub fn get_text<R>(
&self,
line_range: R,
start_col: usize,
end_col: usize,
opts: &GetTextOpts,
) -> Result<impl SuperIterator<String> + use<R>, 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> + use<R>, 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.
pub 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.
pub 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.
pub fn is_valid(&self) -> bool
pub fn is_valid(&self) -> bool
Binding to nvim_buf_is_valid().
Checks if a buffer is valid.
pub 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.
pub 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.
pub 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.
pub 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.
pub fn set_name<Name>(&mut self, name: Name) -> Result<(), Error>
pub fn set_name<Name>(&mut self, name: Name) -> Result<(), Error>
Binding to nvim_buf_set_name().
Sets the full file name for a buffer.
§impl Buffer
impl Buffer
pub 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.
pub 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.
pub fn get_commands(
&self,
opts: &GetCommandsOpts,
) -> Result<impl SuperIterator<CommandInfos> + use<>, Error>
pub fn get_commands( &self, opts: &GetCommandsOpts, ) -> Result<impl SuperIterator<CommandInfos> + use<>, Error>
Binding to nvim_buf_get_commands().
§impl Buffer
impl Buffer
pub fn get_option<Opt>(&self, name: &str) -> Result<Opt, Error>where
Opt: FromObject,
👎Deprecated since 0.5.0: use get_option_value instead
pub fn get_option<Opt>(&self, name: &str) -> Result<Opt, Error>where
Opt: FromObject,
get_option_value insteadBinding to nvim_buf_get_option().
Gets a buffer option value.
pub fn set_option<V>(&mut self, name: &str, value: V) -> Result<(), Error>where
V: ToObject,
👎Deprecated since 0.5.0: use set_option_value instead
pub fn set_option<V>(&mut self, name: &str, value: V) -> Result<(), Error>where
V: ToObject,
set_option_value insteadBinding 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).
§impl Buffer
impl Buffer
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>,
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.
pub 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.
pub 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.
pub 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.
pub fn get_extmarks<NsId>(
&self,
ns_id: NsId,
start: ExtmarkPosition,
end: ExtmarkPosition,
opts: &GetExtmarksOpts,
) -> Result<impl SuperIterator<(u32, usize, usize, Option<ExtmarkInfos>)> + use<NsId>, Error>where
NsId: Into<GetExtmarksNamespaceId>,
pub fn get_extmarks<NsId>(
&self,
ns_id: NsId,
start: ExtmarkPosition,
end: ExtmarkPosition,
opts: &GetExtmarksOpts,
) -> Result<impl SuperIterator<(u32, usize, usize, Option<ExtmarkInfos>)> + use<NsId>, Error>where
NsId: Into<GetExtmarksNamespaceId>,
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.
pub 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 BufferExt for Buffer
impl BufferExt for Buffer
Source§fn get_lines(
&self,
line_range: RangeInclusive<usize>,
strict_indexing: bool,
) -> Result<Box<dyn SuperIterator<String>>, Error>
fn get_lines( &self, line_range: RangeInclusive<usize>, strict_indexing: bool, ) -> Result<Box<dyn SuperIterator<String>>, Error>
Source§fn set_text_at_cursor_pos(&mut self, text: &str)
fn set_text_at_cursor_pos(&mut self, text: &str)
text at the current cursor position in the active buffer. Read moreSource§fn get_buf_type(&self) -> Option<String>
fn get_buf_type(&self) -> Option<String>
buftype option. Read morefn get_channel(&self) -> Option<u32>
Source§fn get_pid(&self) -> Result<String>
fn get_pid(&self) -> Result<String>
Source§fn get_text_between(
&self,
start: (usize, usize),
end: (usize, usize),
boundary: TextBoundary,
) -> Result<String>
fn get_text_between( &self, start: (usize, usize), end: (usize, usize), boundary: TextBoundary, ) -> Result<String>
nvim_oxi::api::Buffer. Read morefn is_terminal(&self) -> bool
fn send_command(&self, cmd: &str) -> Option<()>
§impl<'de> Deserialize<'de> for Buffer
impl<'de> Deserialize<'de> for Buffer
§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Buffer, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Buffer, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
§impl FromObject for Buffer
impl FromObject for Buffer
§impl Serialize for Buffer
impl Serialize for Buffer
§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
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§
§impl<T> AnySync for T
impl<T> AnySync for T
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,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> IntoResult<T> for T
impl<T> IntoResult<T> for T
§type Error = Infallible
type Error = Infallible
Result.§fn into_result(self) -> Result<T, <T as IntoResult<T>>::Error>
fn into_result(self) -> Result<T, <T as IntoResult<T>>::Error>
Result.§impl<D> OwoColorize for D
impl<D> OwoColorize for D
§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg] or
a color-specific method, such as [OwoColorize::green], Read more§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg] or
a color-specific method, such as [OwoColorize::on_yellow], Read more