-
-
Notifications
You must be signed in to change notification settings - Fork 38
History
Will Hopkins edited this page Jul 2, 2023
·
2 revisions
The History keeps track of the buffers you access using a ringbuffer, and provides an API for accessing Buffer objects from the history.
You can access the history using require("cokeline.history")
, or through the global _G.cokeline.history
.
The History object provides these methods:
---Adds a Buffer object to the history
function History:push(bufnr: int)
end
---Removes and returns the oldest Buffer object in the history
function History:pop(): Buffer | nil
end
---Returns a list of Buffer objects in the history,
---ordered from oldest to newest
function History:list(): Buffer[]
end
---Returns an iterator of Buffer objects in the history,
---ordered from oldest to newest
function History:iter(): fun(): Buffer | nil
end
---Get a Buffer object by history index
function History:get(idx: int): Buffer | nil
end
---Get a Buffer object representing the last-accessed buffer (before the current one)
function History:last(): Buffer | nil
end
---Returns true if the history is empty
function History:is_empty(): boolean
end
---Returns the maximum number of buffers that can be stored in the history
function History:capacity(): int
end
---Returns true if the history contains the given buffer
function History:contains(bufnr: int): bool
end
---Returns the number of buffers in the history
function History:len(): int
end
- 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.