-
-
Notifications
You must be signed in to change notification settings - Fork 38
Adding is_last and is_first to buffer return #69
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
Conversation
Note: as it looks like #54 is dead (or at least the contributor is not responsive), and I really like this feature, this is another attempt at getting it mainlined while excluding questioned parts of the aforementioned PR. If this is not acceptable, let me know and I can will happily rescind this PR |
Also, cokeline example for this config local get_hex = require("cokeline.utils").get_hex
local active_bg_color = '#931E9E'
local inactive_bg_color = get_hex('Normal', 'bg')
local bg_color = get_hex('ColorColumn', 'bg')
require('cokeline').setup({
show_if_buffers_are_at_least = 1,
mappings = {
cycle_prev_next = true
},
default_hl = {
bg = function(buffer)
if buffer.is_focused then
return active_bg_color
end
end,
},
components = {
{
text = function(buffer)
local _text = ''
if buffer.index > 1 then _text = ' ' end
if buffer.is_focused or buffer.is_first then
_text = _text .. ''
end
return _text
end,
fg = function(buffer)
if buffer.is_focused then
return active_bg_color
elseif buffer.is_first then
return inactive_bg_color
end
end,
bg = function(buffer)
if buffer.is_focused then
if buffer.is_first then
return bg_color
else
return inactive_bg_color
end
elseif buffer.is_first then
return bg_color
end
end
},
{
text = function(buffer)
local status = ''
if buffer.is_readonly then
status = '➖'
elseif buffer.is_modified then
status = ''
end
return status
end,
},
{
text = function(buffer)
return " " .. buffer.devicon.icon
end,
fg = function(buffer)
if buffer.is_focused then
return buffer.devicon.color
end
end
},
{
text = function(buffer)
return buffer.unique_prefix .. buffer.filename
end,
fg = function(buffer)
if(buffer.diagnostics.errors > 0) then
return '#C95157'
end
end,
style = function(buffer)
local text_style = 'NONE'
if buffer.is_focused then
text_style = 'bold'
end
if buffer.diagnostics.errors > 0 then
if text_style ~= 'NONE' then
text_style = text_style .. ',underline'
else
text_style = 'underline'
end
end
return text_style
end
},
{
text = function(buffer)
local errors = buffer.diagnostics.errors
if(errors <= 9) then
errors = ''
else
errors = "🙃"
end
return errors .. ' '
end,
fg = function(buffer)
if buffer.diagnostics.errors == 0 then
return '#3DEB63'
elseif buffer.diagnostics.errors <= 9 then
return '#DB121B'
end
end
},
{
text = '',
delete_buffer_on_left_click = true
},
{
text = function(buffer)
if buffer.is_focused or buffer.is_last then
return ''
else
return ' '
end
end,
fg = function(buffer)
if buffer.is_focused then
return active_bg_color
elseif buffer.is_last then
return inactive_bg_color
else
return bg_color
end
end,
bg = function(buffer)
if buffer.is_focused then
if buffer.is_last then
return bg_color
else
return inactive_bg_color
end
elseif buffer.is_last then
return bg_color
end
end
}
},
}) |
could you add the config example to the |
No problem! I have added the example to the bottom of the README |
Essentially the same concept as PR 54, though I didn't include the later about exposing all buffers.
Adding the

is_first
andis_last
buffer options allows configurations such as thisWhere the first and last buffer have different left and right icons depending on if they are the first/last or not