Buffer Class
- class pynvim.api.Buffer(session: Nvim, code_data: Tuple[int, Any])[source]
A remote Nvim buffer.
- add_highlight(hl_group: str, line: int, col_start: int = 0, col_end: int = -1, src_id: int = -1, async_: bool | None = None, **kwargs: Any) int [source]
Add a highlight to the buffer.
- append(lines: str | bytes | List[str | bytes], index: int = -1) None [source]
Append a string or list of lines to the buffer.
- clear_highlight(src_id: int, line_start: int = 0, line_end: int = -1, async_: bool | None = None, **kwargs: Any) None [source]
Clear highlights from the buffer.
- property loaded: bool
Return True if the buffer is valid and loaded.
- property name: str
Get the buffer name.
- property number: int
Get the buffer number.
- range(start: int, end: int) Range [source]
Return a Range object, which represents part of the Buffer.
- update_highlights(src_id: int, hls: List[Tuple[str, int] | Tuple[str, int, int, int]], clear_start: int | None = None, clear_end: int = -1, clear: bool = False, async_: bool = True) None [source]
Add or update highlights in batch to avoid unnecessary redraws.
A src_id must have been allocated prior to use of this function. Use for instance nvim.new_highlight_source() to get a src_id for your plugin.
hls should be a list of highlight items. Each item should be a list or tuple on the form (“GroupName”, linenr, col_start, col_end) or (“GroupName”, linenr) to highlight an entire line.
By default existing highlights are preserved. Specify a line range with clear_start and clear_end to replace highlights in this range. As a shorthand, use clear=True to clear the entire buffer before adding the new highlights.
- property valid: bool
Return True if the buffer still exists.