Skip to content

Commit

Permalink
ref(render): use new highlight groups
Browse files Browse the repository at this point in the history
  • Loading branch information
Iron-E committed Jan 13, 2024
1 parent e1386b5 commit 9f0d6d2
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions lua/barbar/ui/render.lua
Original file line number Diff line number Diff line change
Expand Up @@ -420,8 +420,14 @@ local function get_bufferline_containers(data, bufnrs, refocus)
end
end

--- the start of all rendered highlight names
local hl_prefix = 'Buffer' .. activity_name

--- the suffix of some (eventually all) rendered highlight names
local hl_suffix = (modified and 'Mod') or (pinned and 'Pin') or ''

local buffer_name = buffer_data.name or '[no name]'
local buffer_hl = wrap_hl('Buffer' .. activity_name .. (modified and 'Mod' or ''))
local buffer_hl = wrap_hl(hl_prefix .. hl_suffix)

local icons_option = buffer.get_icons(activity_name, modified, pinned)

Expand All @@ -436,21 +442,21 @@ local function get_bufferline_containers(data, bufnrs, refocus)
--- @type barbar.ui.node
local buffer_index = { hl = '', text = '' }
if icons_option.buffer_index then
buffer_index.hl = wrap_hl('Buffer' .. activity_name .. 'Index')
buffer_index.hl = wrap_hl(hl_prefix .. 'Index')
buffer_index.text = style_number(i, icons_option.buffer_index) .. ' '
end

--- The buffer number
--- @type barbar.ui.node
local buffer_number = { hl = '', text = '' }
if icons_option.buffer_number then
buffer_number.hl = wrap_hl('Buffer' .. activity_name .. 'Number')
buffer_number.hl = wrap_hl(hl_prefix .. 'Number')
buffer_number.text = style_number(bufnr, icons_option.buffer_number) .. ' '
end

--- The close icon
--- @type barbar.ui.node
local button = {hl = buffer_hl, text = ''}
local button = {hl = wrap_hl(hl_prefix .. 'Btn' .. hl_suffix), text = ''}

local button_icon = icons_option.button
if button_icon and #button_icon > 0 then
Expand All @@ -477,7 +483,7 @@ local function get_bufferline_containers(data, bufnrs, refocus)
name.text = strcharpart(name.text, 1)
end

jump_letter.hl = wrap_hl('Buffer' .. activity_name .. 'Target')
jump_letter.hl = wrap_hl(hl_prefix .. 'Target')
if letter then
jump_letter.text = letter
if icons_option.filetype.enabled and #name.text > 0 then
Expand All @@ -493,14 +499,14 @@ local function get_bufferline_containers(data, bufnrs, refocus)
or iconHl

icon.hl = icons_option.filetype.custom_colors and
wrap_hl('Buffer' .. activity_name .. 'Icon') or
wrap_hl(hl_prefix .. 'Icon') or
(hlName and wrap_hl(hlName) or buffer_hl)
icon.text = #name.text > 0 and iconChar .. ' ' or iconChar
end

--- @type barbar.ui.node
local left_separator = {
hl = clickable .. wrap_hl('Buffer' .. activity_name .. 'Sign'),
hl = clickable .. wrap_hl(hl_prefix .. 'Sign'),
text = icons_option.separator.left,
}

Expand All @@ -517,21 +523,21 @@ local function get_bufferline_containers(data, bufnrs, refocus)

state.for_each_counted_enabled_diagnostic(bufnr, icons_option.diagnostics, function(count, idx, option)
table_insert(container.nodes, {
hl = wrap_hl('Buffer' .. activity_name .. severity[idx]),
hl = wrap_hl(hl_prefix .. severity[idx]),
text = ' ' .. option.icon .. count,
})
end)

state.for_each_counted_enabled_git_status(bufnr, icons_option.gitsigns, function(count, idx, option)
table_insert(container.nodes, {
hl = wrap_hl('Buffer' .. activity_name .. idx:upper()),
hl = wrap_hl(hl_prefix .. idx:upper()),
text = ' ' .. option.icon .. count,
})
end)

--- @type barbar.ui.node
local right_separator = {
hl = clickable .. wrap_hl('Buffer' .. activity_name .. 'SignRight'),
hl = clickable .. wrap_hl(hl_prefix .. 'SignRight'),
text = icons_option.separator.right,
}

Expand Down

0 comments on commit 9f0d6d2

Please sign in to comment.