-
-
Notifications
You must be signed in to change notification settings - Fork 38
Buffer
Some of the configuration options can be functions that take a Buffer
as a
single parameter. This is useful as it allows users to set the values of
components dynamically based on the buffer that component is being rendered
for.
Buffer = {
index = integer,
number = integer,
type = string,
is_focused = boolean,
is_modified = boolean,
is_readonly = boolean,
path = string,
unique_prefix = string,
filename = string,
filetype = string,
pick_letter = char,
devicon = { icon = string, color = string },
diagnostics = {
errors = integer,
warnings = integer,
infos = integer,
hints = integer
}
}
The buffer's order in the bufferline (1 for the first buffer, 2 for the second one, etc.).
The buffer's internal number as reported by :ls
Whether the buffer is currently focused
The buffer is the first visible buffer in the tab bar.
The buffer is the last visible buffer in the tab bar.
The mouse is hovering over the buffer
This is a special variable in that it will only be true for the hovered component on render. This is to allow components to respond to hover events individually without managing component state. If you just need the hovered bufnr, you can use require('cokeline.hover').hovered().bufnr
.
The buffer's type as reported by :echo &buftype
.
The buffer's filetype as reported by :echo &filetype
.
The buffer's full path
The buffer's filename
A unique prefix used to distinguish buffers with the same filename stored in different directories. For example, if we have two files bar/foo.md
and baz/foo.md
, then the first will have bar/
as its unique prefix and the second one will have baz/
.
The letter that is displayed when picking a buffer to either focus or close it.
This needs the kyazdani42/nvim-web-devicons
plugin to be installed.
The color is in hex format.
An icon representing the buffer's filetype.
The colors of the devicon in hexadecimal format (useful to be passed to a component's fg
field (see the Components
section).
- diagnostics.errors: integer
- diagnostics.warnings: integer
- diagnostics.infos: integer
- diagnostics.hints: integer
The values in this table are the ones reported by Neovim's built in LSP interface.
---@param self Buffer
---Deletes the buffer
function Buffer:delete()
---@param self Buffer
---Focuses the buffer
function Buffer:focus()
---@param self Buffer
---@return number
---Returns the number of lines in the buffer
function Buffer:lines()
---@param self Buffer
---@return string[]
---Returns the buffer's lines
function Buffer:text()
---@param buf Buffer
---@return boolean
---Returns true if the buffer is valid
function Buffer:is_valid()
- pick(goal) Focus or close a buffer using pick letters.
- by_step(goal, step) Focus or close a buffer using a relative offset (-1, 1, etc.)
- by_index(goal, idx) Focus or close a buffer by its index.
- buf_delete(bufnr, wipe) Delete the given buffer while maintaining window layout.
-
get_hl(group_name)
Memoized wrapper around
nvim_get_hl
-
get_hl_attr(group_name, attr)
Get a single attribute from a hlgroup. Memoized with same cache as
get_hl
.
- is_visible(bufnr) Returns true if the buffer is visible.
- get_current() Returns the Buffer object for the current buffer.
- get_buffer(bufnr) Returns the Buffer object for the given bufnr, if valid.
- get_visible() Returns a list of visible Buffer objects.
- get_valid_buffers() Returns a list of valid buffers.
- move_buffer(buffer, target) Move a buffer to a different position.
- release_taken_letter(bufnr) Release the pick letter for a Buffer object.
- update_current(tabnr)
- fetch_tabs() Update the list of tabpges.
- get_tabs() Returns a list of Tabpage objects.
- get_tabpage(tabnr) Returns the Tabpage object for tabnr, if valid.
- push(bufnr) Push an item into the history.
- pop() Pop the last item off of the history.
- list() Returns the history items as a (copied) list.
- iter() Returns an iterator over the history items.
-
get(idx)
Get the item at history index
idx
, if any. - last() Peek the last item in the history, without removing it.
-
contains(bufnr)
Check if the history contains the given
bufnr
. - capacity() Returns the configured capacity.
- len() Returns the number of items in the history.