Open ofseed opened 2 months ago
Hi @ofseed,
I'm not sure what you mean? they customize the icon too? as in they should be able to or they have to as well?
When using tab mode, there's buffers
in name_formatter
, but there's no equivalent for get_element_icon
. We can only get information about the currently active buffer
My usage:
mode = "tabs",
name_formatter = function(args)
if vim.bo[args.bufnr].buftype ~= "" then
for _, bufnr in ipairs(args.buffers) do
if vim.bo[bufnr].buftype == "" then
return vim.fn.fnamemodify(vim.api.nvim_buf_get_name(bufnr), ":t")
end
end
end
end,
get_element_icon = function(args)
local loaded, devicons = pcall(require, "nvim-web-devicons")
if not loaded then
return ""
end
if vim.bo[args.bufnr].buftype ~= "" then
for _, bufnr in ipairs(args.buffers) do
if vim.bo[bufnr].buftype == "" then
return devicons.get_icon(
vim.fn.fnamemodify(vim.api.nvim_buf_get_name(bufnr), ":t"),
nil,
{ default = true }
)
end
end
end
end,
I'm not sure what you mean? they customize the icon too? as in they should be able to or they have to as well?
@akinsho I mean they should be able to, because there's no extra information like buffers opened in the tab in current API, we chan only get current active file's filetype for path, even cannot get it's bufnr
@akinsho I have already provided explanations for your questions. Could you please review them again?
@ofseed this will have to wait till I have free time
I just wanted to avoid the message getting lost in the notifications. Thank you.
When a user customized the name by
name_formatter
, they would customize the icon too. I think it should be better to make them have the same arguments, but considering changing the arguments would be a breaking change, I recommend adding all thename_formatter
properties toget_element_icon
.In my usage, I use the tab mode of bufferline, I don't want bufferline to show the name of buffers which has a special buftype when there is a normal buffer that exists in the tabpage.