Skip to content
This repository was archived by the owner on Aug 18, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ Clear the binding of current tab's buffers.

Rename current tab's name.

### :<count>TablineBufferGoto

Move to specified buffer in the tabline

# Configuration

You can customize the behavior of this extension by setting values for any of the following optional parameters.
Expand Down
14 changes: 14 additions & 0 deletions lua/tabline.lua
Original file line number Diff line number Diff line change
Expand Up @@ -803,6 +803,19 @@ function M.buffer_next()
end
end

function M.buffer_goto( index )
local next
for _, buffer in pairs(M.buffers) do
local next_buffer = M.buffers[M.mod(tonumber(index), #M.buffers)]
if buffer.current and next_buffer ~= nil then
next = next_buffer.bufnr
end
end
if next ~= nil then
vim.cmd("silent! buffer " .. next)
end
end

function M.buffer_previous()
local previous
for i, buffer in pairs(M.buffers) do
Expand Down Expand Up @@ -939,6 +952,7 @@ function M.setup(opts)

command! -count TablineBufferNext :lua require'tabline'.buffer_next()
command! -count TablineBufferPrevious :lua require'tabline'.buffer_previous()
command! -count=1 TablineBufferGoTo :lua require'tabline'.buffer_goto(<count>)

command! -nargs=* -complete=file TablineTabNew :lua require'tabline'.tab_new(<f-args>)
command! -nargs=+ -complete=buffer TablineBuffersBind :lua require'tabline'.bind_buffers(<f-args>)
Expand Down