bufferline.nvim
bufferline.nvim copied to clipboard
[feature request] add modified buffer name highlight
hey! is there an ability to add hl to modified buffer in the list? like to have modified yellow, non-modified white, current blue
Hmm you can change the modified icon colour but if I understand correctly you mean change the whole buffer tab styling based on if a buffer is modified.
I think that will be a bit tricky/messy to try and implement (or not, not sure). basically several highlights already change the colour of the buffer text such as diagnostic, visible, inactive etc. I think adding another highlight group there might be possible but think it's getting a little complex now.
yeah, agree on amount of highlights... just thought that having ability to change icon colour, and not having to change name is a bit inconsistent :) can close if decide to not makes things more complex :)
@alex-popov-tech I think maybe it could be added without too much trouble the line is here this "switch" is used to set the buffers colours based on the state of the buffer and atm it only looks at visible and selected or inactive. I guess you could add a check either within each block to change things based on modified or not state.
Tbh that bit is due for a bit of a refactor since I always feel like a giant switch can often be improved, but I think it could work somewhere in there. I personally don't have much motivation to add it since I'm slightly less convinced of the need/having buffers go between like 5 different highlights based on different states is a bit much but if it was hidden behind an option and fit into there without making it even more unwieldy then I wouldn't mind adding it
Hi, @akinsho!
I would like to have this feature as well, so I forked your repo and implemented your suggestions. I was able to get the follwoing:

where in this case, my color scheme is:
current buffer : fg = black, bg = green visible buffer : fg = grey. bg = black modified current buffer : fg = black, bg = yellow modified visible buffer : fg = yellow, bg = black
I was pretty satisfied. However, if I activate the diagnostic indicator, things look like the following:

where red indicate buffer that has diagnostic.
As we can see, the background size for the diagnostics is different from the one for current buffer (and visible buffer). I tried to fix this but I do not really understand how the sizing and padding work and how they are defined. If you can help, it will be much appreciated.
@iwijaya2 the diagnostics only apply to the start of the buffer name up till the count/indicator, this is by design because it was designed to only colour the text. As is the case in your example, the diagnostics are highlighting the background instead, then this will happen. This issue highlights what I was describing when I talked about the complexity of this feature. nvim doesn't really have a nice API for having a lot of dynamic highlights in the tab or statusline and this plugin has already pushed things quite far. From my perspective this kind of issue is inevitable, even if you are able to get around this there are so many highlights applied in different ways that this is bound to creep back up. Generally, I don't intend to allow a bunch of new highlights unless the neovim API changes.
I see. I did try to have background highlight because for me it is better indicator than icon. I did introduce a bunch of new highlights when I made the modification, so I understand your concern. I am pretty satisfied the way it is now. Thank you for developing this plugin!