Replies: 6 comments 1 reply
-
Yes, you can set a buffer line by tabby.nvim. But you can only use low level API to make it, because the layout of high level is fixed. Here is a simple example: local components = function()
local coms = {}
local cur_bufid = vim.api.nvim_get_current_buf()
for _, bufid in ipairs(vim.api.nvim_list_bufs()) do
if vim.api.nvim_buf_is_valid(bufid) and vim.bo[bufid].buflisted then
local hl = 'TabLine'
if bufid == cur_bufid then
hl = 'TabLineSel'
end
local buf_name = vim.fn.fnamemodify(vim.api.nvim_buf_get_name(bufid), ':~:.')
table.insert(coms, {
type = 'text',
text = {
string.format(' %d: %s ', bufid, buf_name),
hl = hl,
},
})
table.insert(coms, {
type = 'text',
text = {
' ',
hl = 'TabLineFill',
},
})
end
end
return coms
end
require('tabby').setup({
components = components,
}) |
Beta Was this translation helpful? Give feedback.
-
But for now, the customer handler of mouse click not implemented(in TODO list). So cannot click buffer label to switch buffer yet. |
Beta Was this translation helpful? Give feedback.
-
How could I put the buffers at the tail of my config? |
Beta Was this translation helpful? Give feedback.
-
You can put a separator in the front of the components array. { type = "spring" } and the buffer labels will be pushed to the end. Do you mind I covert this issue to a discussion? I think this may be helping other users. |
Beta Was this translation helpful? Give feedback.
-
Could you be a bit more specific? How would I put these buffers into my current config seen above?
I think that's a great idea :D |
Beta Was this translation helpful? Give feedback.
-
Current config with buffers... local util = require('tabby.util')
local hl_tabline = util.extract_nvim_hl('TabLine')
local hl_normal = util.extract_nvim_hl('Normal')
local hl_tabline_sel = util.extract_nvim_hl('TabLineSel')
local active_tab_hl = { fg = hl_normal.fg, bg = hl_normal.bg, style = 'bold' }
local inactive_tab_hl = { fg = hl_tabline.fg, bg = hl_tabline.bg }
local components = function()
local coms = {
{
type = 'text',
text = {
' ',
hl = 'TabLineFill'
}
},
{
type = 'text',
text = {
' ',
hl = { fg = hl_tabline_sel.fg, bg = hl_tabline_sel.bg, style = 'bold' },
},
},
{
type = 'text',
text = {
' ',
hl = 'TabLineFill'
}
},
}
local tabs = vim.api.nvim_list_tabpages()
local current_tab = vim.api.nvim_get_current_tabpage()
for _, tabid in ipairs(tabs) do
if tabid == current_tab then
table.insert(coms, {
type = 'tab',
tabid = tabid,
label = {
' ' .. vim.api.nvim_tabpage_get_number(tabid) .. ' ',
hl = active_tab_hl
},
})
end
if tabid ~= current_tab then
table.insert(coms, {
type = 'tab',
tabid = tabid,
label = {
' ' .. vim.api.nvim_tabpage_get_number(tabid) .. ' ',
hl = inactive_tab_hl
},
})
end
end
table.insert(coms,
{
type = 'text',
text = {
' ',
hl = 'TabLineFill'
}
}
)
table.insert(coms, { type = 'spring' } )
local cur_bufid = vim.api.nvim_get_current_buf()
for _, bufid in ipairs(vim.api.nvim_list_bufs()) do
if vim.api.nvim_buf_is_valid(bufid) and vim.bo[bufid].buflisted then
local hl = inactive_tab_hl
if bufid == cur_bufid then
hl = active_tab_hl
end
local buf_name = vim.fn.fnamemodify(vim.api.nvim_buf_get_name(bufid), ':~:.')
table.insert(coms, {
type = 'text',
text = {
string.format(' %d %s ', bufid, buf_name),
hl = hl,
},
})
end
end
return coms
end
require('tabby').setup{
components = components,
}
BTW, do you know how to remove the buffer numbers? I only want the buffer's name. |
Beta Was this translation helpful? Give feedback.
-
I know that in the README, tabby.nvim is not supposed to be a buffers list but it also says that it is possible with low-level api...
What would the configuration for this look like (assuming it's possible)?
Here's my config btw...
Beta Was this translation helpful? Give feedback.
All reactions