Skip to content

Commit

Permalink
feat: add fill_hl config option
Browse files Browse the repository at this point in the history
Make the colors of the filler space configurable.
  • Loading branch information
folliehiyuki authored and willothy committed Jun 29, 2023
1 parent 7a487d9 commit 61c89e2
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 5 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,9 @@ require('cokeline').setup({
style = 'attr1,attr2,...' | function(buffer) -> 'attr1,attr2,...',
},

-- The highlight group used to fill the tabline space
fill_hl = 'TabLineFill',

-- A list of components to be rendered for each buffer. Check out the section
-- below explaining what this value can be set to.
-- default: see `/lua/cokeline/defaults.lua`
Expand Down
2 changes: 2 additions & 0 deletions doc/cokeline.txt
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ The valid keys are:
style = 'attr1,attr2,...' | function(buffer) -> 'attr1,attr2,...',
},

-- The highlight group used to fill the tabline space
fill_hl = 'TabLineFill',

-- A list of components to be rendered for each buffer (see
-- |cokeline-components|).
Expand Down
2 changes: 2 additions & 0 deletions lua/cokeline/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ local defaults = {
style = "NONE",
},

fill_hl = 'TabLineFill',

---@type Component[]
components = {
{
Expand Down
2 changes: 1 addition & 1 deletion lua/cokeline/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ _G.cokeline.tabline = function()
opt.showtabline = 0
return
end
return rendering.render(visible_buffers)
return rendering.render(visible_buffers, _G.cokeline.config.fill_hl)
end

return {
Expand Down
9 changes: 5 additions & 4 deletions lua/cokeline/rendering.lua
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ end
---the list of visible buffers, figures out which components to display, and
---returns a list of pre-render components
---@param visible_buffers Buffer[]
---@return string
---@return table|string
local prepare = function(visible_buffers)
local sidebar_components = sidebar.get_components()
local rhs_components = rhs.get_components()
Expand Down Expand Up @@ -178,15 +178,16 @@ end
---the list of visible buffers, figures out which components to display and
---returns their rendered version.
---@param visible_buffers Buffer[]
---@param fill_hl string
---@return string
local render = function(visible_buffers)
local render = function(visible_buffers, fill_hl)
local cx = prepare(visible_buffers)
return components.render(cx.sidebar)
.. components.render(cx.buffers)
.. "%#TabLine#"
.. "%#" .. fill_hl .. "#"
.. string.rep(" ", cx.gap)
.. components.render(cx.rhs)
.. "%#TabLine#"
.. "%#" .. fill_hl .. "#"
end

return {
Expand Down

0 comments on commit 61c89e2

Please sign in to comment.