Skip to content

Commit

Permalink
Merge pull request #433 from pwntester/fix_429
Browse files Browse the repository at this point in the history
Upgrade to get_hl_color
  • Loading branch information
pwntester authored Nov 13, 2023
2 parents 154721c + f390f09 commit cc3f0a0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
21 changes: 14 additions & 7 deletions lua/octo/ui/bubbles.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,20 @@ local function make_bubble(content, highlight_group, opts)
local left_delimiter = (left_margin .. margin) .. conf.left_bubble_delimiter
local right_delimiter = conf.right_bubble_delimiter .. (right_margin .. margin)
local delimiter_color = colors.get_background_color_of_highlight_group(highlight_group)
local delimiter_highlight_group = colors.create_highlight(delimiter_color, { mode = "foreground" })

return {
{ left_delimiter, delimiter_highlight_group },
{ body, highlight_group },
{ right_delimiter, delimiter_highlight_group },
}
if delimiter_color then
local delimiter_highlight_group = colors.create_highlight(delimiter_color, { mode = "foreground" })
return {
{ left_delimiter, delimiter_highlight_group },
{ body, highlight_group },
{ right_delimiter, delimiter_highlight_group },
}
else
return {
{ left_delimiter, highlight_group },
{ body, highlight_group },
{ right_delimiter, highlight_group },
}
end
end

local function make_user_bubble(name, is_viewer, opts)
Expand Down
6 changes: 3 additions & 3 deletions lua/octo/ui/colors.lua
Original file line number Diff line number Diff line change
Expand Up @@ -168,15 +168,15 @@ local function color_is_bright(r, g, b)
-- Counting the perceptive luminance - human eye favors green color
local luminance = (0.299 * r + 0.587 * g + 0.114 * b) / 255
if luminance > 0.5 then
return true -- Bright colors, black font
return true -- Bright colors, black font
else
return false -- Dark colors, white font
end
end

function M.get_background_color_of_highlight_group(highlight_group_name)
local highlight_group = vim.api.nvim_get_hl_by_name(highlight_group_name, true)
local highlight_group_normal = vim.api.nvim_get_hl_by_name("Normal", true)
local highlight_group = vim.api.nvim_get_hl(0, { name = highlight_group_name })
local highlight_group_normal = vim.api.nvim_get_hl(0, { name = "Normal" })
local background_color = highlight_group.background or highlight_group_normal.background
if background_color then
return string.format("#%06x", background_color)
Expand Down

0 comments on commit cc3f0a0

Please sign in to comment.