From 09778072d845edcc367dc3207657e027ee2e914b Mon Sep 17 00:00:00 2001 From: Tamton Aquib Date: Wed, 27 Mar 2024 22:20:03 +0530 Subject: [PATCH] ref(winbar): pad the hex with 6 zeroes using string.format --- lua/rest-nvim/result/winbar.lua | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/lua/rest-nvim/result/winbar.lua b/lua/rest-nvim/result/winbar.lua index 6ec0e18e..4994c844 100644 --- a/lua/rest-nvim/result/winbar.lua +++ b/lua/rest-nvim/result/winbar.lua @@ -59,16 +59,8 @@ winbar.pane_map = { ---@param name string Highlighting group name ---@return string local function get_hl_group_fg(name) - -- If the HEX color has a zero as the first character, `string.format` will skip it - -- so we have to add it manually later - local hl_fg = string.format("%02X", vim.api.nvim_get_hl(0, { name = name, link = false }).fg) - if #hl_fg == 4 then - hl_fg = "00" .. hl_fg - elseif #hl_fg == 5 then - hl_fg = "0" .. hl_fg - end - hl_fg = "#" .. hl_fg - return hl_fg + -- This will still error out if the highlight doesn't exist + return string.format("#%06X", vim.api.nvim_get_hl(0, { name = name, link = false }).fg) end ---Set the results window winbar highlighting groups