-
-
Notifications
You must be signed in to change notification settings - Fork 198
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(ui): pass formatter opts to icon fetcher as well #944
base: main
Are you sure you want to change the base?
Conversation
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 |
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, |
@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 |
@@ -136,7 +136,7 @@ The available configuration are: | |||
}, | |||
color_icons = true | false, -- whether or not to add the filetype icon highlights | |||
get_element_icon = function(element) | |||
-- element consists of {filetype: string, path: string, extension: string, directory: string} | |||
-- element consists of {filetype: string, extension: string, directory: string, type:string?}, and all the properties same as the `name_formatter` function |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This removes path which is a breaking change and adds type which it doesn't explain here what that is?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
path
is included in name_formatter
arguments, which I explained will be fully included. So it simplifies the expression, not changing the behavior.
filetype = vim.bo[buf.id].filetype, | ||
directory = is_directory, | ||
extension = buf.extension, | ||
type = buf.buftype, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we passing in the buffer type at all?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I kept this because we have done this already, you can see it there:
bufferline.nvim/lua/bufferline/models.lua
Line 118 in 0b2fd86
type = tab.buftype, |
Actually, I found it might be a mistake, it may be intended to be used here
bufferline.nvim/lua/bufferline/utils/init.lua
Line 229 in 0b2fd86
if type == "terminal" then return webdev_icons.get_icon(type) end |
But the
type
here will be the global variable included in Lua stdlib, the type
function, so it's a false condition. type
was not documented, but I kept it to avoid underlying breaking change.
@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.