akinsho / akinsho/bufferline.nvim

[Feature Request]: Expose next_item API

Offen
#1,032 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
enhancement
Vorherrschende Sprache
Lua
Sterne
4.4k
Forks
240
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

### What?

Expose next_item api, so as user could get a next buffer a potential call of cycle in a given direction or BufferLineCyclePrev cmd move to.

### Why?

In order to easier integrate plugins such as bufdel.
At the moment a user is required to call a private API (I guess so) and duplicate a part of cycle command, e.g.

```lua
{
"ojroques/nvim-bufdel",
opts = {
next = function()
-- TODO: if it's first then next, otherwise prev
local state = require("bufferline.lazy").require("bufferline.state")
local index = require("bufferline.commands").get_current_element_index(state)
if not index then
return
end

local next_index = index - 1

if next_index <= 0 then
next_index = #state.components
end

local item = state.components[next_index]
if not item then
return vim.notify("This " .. item.type .. " does not exist", vim.log.levels.ERROR)
end
return item.id
end,
quit = true,
},
},
```

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.