diff --git a/lua/tokyonight/extra/zathura.lua b/lua/tokyonight/extra/zathura.lua index 39b5af27..7a691a4b 100644 --- a/lua/tokyonight/extra/zathura.lua +++ b/lua/tokyonight/extra/zathura.lua @@ -4,6 +4,36 @@ local M = {} --- @param colors ColorScheme function M.generate(colors) + local zathuraColors = {} + for colorsK, colorsV in pairs(colors) do + -- Add any color names we need to convert from hex to decimal + local convertColors = { "yellow", "green" } + -- Return true if a table contains a value + ---@param tab table Table to search in + ---@param val any Value to locate in table + local function contains(tab, val) + for _, value in ipairs(tab) do + if value == val then + return true + end + end + return false + end + if contains(convertColors, colorsK) then + local colorNames = { "R", "G", "B" } + -- Start at 2 to skip # + local hexIndex = 2 + -- Inserts values into table in form of {color}Decimal{R,G,B} + for i = 1, #colorNames do + local zathuraColorsK = colorsK .. "Decimal" .. colorNames[i] + local zathuraColorsV = tonumber(colorsV:sub(hexIndex, hexIndex + 1), 16) + zathuraColors[zathuraColorsK] = zathuraColorsV + hexIndex = hexIndex + 2 + end + end + -- Add other colors into table normally + zathuraColors[colorsK] = colorsV + end local zathura = util.template( [[ # Tokyonight color theme for Zathura @@ -31,8 +61,8 @@ set inputbar-bg "${bg}" set inputbar-fg "${fg}" set statusbar-bg "${bg}" set statusbar-fg "${fg}" -set highlight-color "${yellow}" -set highlight-active-color "${green}" +set highlight-color "rgba(${yellowDecimalR}, ${yellowDecimalG}, ${yellowDecimalB}, 0.5)" +set highlight-active-color "rgba(${greenDecimalR}, ${greenDecimalG}, ${greenDecimalB}, 0.5)" set default-bg "${bg}" set default-fg "${fg}" set render-loading true @@ -45,7 +75,7 @@ set render-loading-bg "${fg}" set recolor-lightcolor "${bg}" set recolor-darkcolor "${fg}" ]], - colors + zathuraColors ) return zathura end