Skip to content

Commit 0977807

Browse files
tamton-aquibNTBBloodbath
authored andcommitted
ref(winbar): pad the hex with 6 zeroes using string.format
1 parent 1bad966 commit 0977807

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

lua/rest-nvim/result/winbar.lua

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -59,16 +59,8 @@ winbar.pane_map = {
5959
---@param name string Highlighting group name
6060
---@return string
6161
local function get_hl_group_fg(name)
62-
-- If the HEX color has a zero as the first character, `string.format` will skip it
63-
-- so we have to add it manually later
64-
local hl_fg = string.format("%02X", vim.api.nvim_get_hl(0, { name = name, link = false }).fg)
65-
if #hl_fg == 4 then
66-
hl_fg = "00" .. hl_fg
67-
elseif #hl_fg == 5 then
68-
hl_fg = "0" .. hl_fg
69-
end
70-
hl_fg = "#" .. hl_fg
71-
return hl_fg
62+
-- This will still error out if the highlight doesn't exist
63+
return string.format("#%06X", vim.api.nvim_get_hl(0, { name = name, link = false }).fg)
7264
end
7365

7466
---Set the results window winbar highlighting groups

0 commit comments

Comments
 (0)