Adding is_last and is_first to buffer return#69
Merged
Conversation
Contributor
Author
|
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 |
Contributor
Author
|
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
}
},
}) |
Collaborator
|
could you add the config example to the |
Contributor
Author
|
No problem! I have added the example to the bottom of the README |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Essentially the same concept as PR 54, though I didn't include the later about exposing all buffers.
Adding the

is_firstandis_lastbuffer 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