Struct Buffer

Source
pub struct Buffer(/* private fields */);
Expand description

A wrapper around a Neovim buffer handle.

Implementations§

Source§

impl Buffer

Source

pub fn current() -> Self

Shorthand for get_current_buf.

Source

pub fn handle(&self) -> i32

Retrieve buffer’s underlying id/handle

Source

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.

Source

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.

Source

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.

Source

pub fn del_mark(&mut self, name: char) -> Result<(), Error>

Binding to nvim_buf_del_mark().

Deletes a named mark in the buffer.

Source

pub fn del_var(&mut self, name: &str) -> Result<(), Error>

Binding to nvim_buf_del_var().

Removes a buffer-scoped (b:) variable.

Source

pub fn delete(self, opts: &BufDeleteOpts) -> Result<(), Error>

Binding to nvim_buf_delete().

Deletes the buffer (not allowed while textlock is active).

Source

pub fn get_changedtick(&self) -> Result<u32, Error>

Source

pub fn get_keymap( &self, mode: Mode, ) -> Result<impl SuperIterator<KeymapInfos>, Error>

Source

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.

Source

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.

Source

pub fn get_name(&self) -> Result<PathBuf, Error>

Binding to nvim_buf_get_name().

Returns the full filepath of the buffer.

Source

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.

Source

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.

Source

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.

Source

pub fn is_loaded(&self) -> bool

Binding to nvim_buf_is_loaded().

Checks if a buffer is valid and loaded.

Source

pub fn is_valid(&self) -> bool

Binding to nvim_buf_is_valid().

Checks if a buffer is valid.

Source

pub fn line_count(&self) -> Result<usize, Error>

Binding to nvim_buf_line_count().

Returns the number of lines in the given buffer.

Source

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.

Source

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.

Source

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.

Source

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

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.

Source

pub fn set_var<V>(&mut self, name: &str, value: V) -> Result<(), Error>
where V: ToObject,

Binding to nvim_buf_set_var().

Sets a buffer-scoped (b:) variable.

Source§

impl Buffer

Source

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.

Source

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.

Source

pub fn get_commands( &self, opts: &GetCommandsOpts, ) -> Result<impl SuperIterator<CommandInfos>, Error>

Source§

impl Buffer

Source

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.

Source

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

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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 Clone for Buffer

Source§

fn clone(&self) -> Buffer

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Buffer

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Buffer

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for Buffer

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<&Buffer> for Object

Source§

fn from(buf: &Buffer) -> Self

Converts to this type from the input type.
Source§

impl From<Buffer> for Object

Source§

fn from(buf: Buffer) -> Self

Converts to this type from the input type.
Source§

impl<H: Into<BufHandle>> From<H> for Buffer

Source§

fn from(handle: H) -> Self

Converts to this type from the input type.
Source§

impl FromObject for Buffer

Source§

impl Hash for Buffer

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Buffer

Source§

fn eq(&self, other: &Buffer) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Poppable for Buffer

Source§

unsafe fn pop(lstate: *mut State) -> Result<Self, Error>

Pops the value at the top of the stack.
Source§

impl Pushable for Buffer

Source§

unsafe fn push(self, lstate: *mut State) -> Result<c_int, Error>

Pushes all its values on the Lua stack, returning the number of values that it pushed.
Source§

impl Serialize for Buffer

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Eq for Buffer

Source§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoResult<T> for T

Source§

type Error = Infallible

The error type in the returned Result.
Source§

fn into_result(self) -> Result<T, <T as IntoResult<T>>::Error>

Converts the value into a Result.
Source§

impl<T> ToObject for T
where T: Into<Object>,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,