Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(zathura): update template to accomodate new format #642

Open
wants to merge 24 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
3ef5596
Add rgba prefixes
guiltiest-gear Oct 4, 2024
f277d02
Add todo comment
guiltiest-gear Oct 4, 2024
307ee94
Trim # from start of string
guiltiest-gear Oct 4, 2024
a811943
hack: add back # for the options that need it
guiltiest-gear Oct 4, 2024
0723642
fix: forgot two other options that use hex codes
guiltiest-gear Oct 4, 2024
23b7f1f
Undo hacks trim #
guiltiest-gear Oct 4, 2024
c70cbea
Add alpha argument for rgba
guiltiest-gear Oct 4, 2024
b01770c
Convert hex codes into decimals
guiltiest-gear Oct 5, 2024
c6343c7
Pass all other colors normally
guiltiest-gear Oct 5, 2024
402536b
fix: string interpolation for green color now functions properly
guiltiest-gear Oct 5, 2024
0224a9c
Remove todo comment
guiltiest-gear Oct 5, 2024
6168624
Add fix comment
guiltiest-gear Oct 5, 2024
1bc5642
fix: incorrect bounds for obtaining blue component
guiltiest-gear Oct 5, 2024
e77df63
Use more compact field access for substrings
guiltiest-gear Oct 5, 2024
3f6aa88
Remove tostring function
guiltiest-gear Oct 5, 2024
ec4ad55
Rename parameter to reduce confusion
guiltiest-gear Oct 5, 2024
d5f438a
refactor: inserting colors is more concise now
guiltiest-gear Oct 5, 2024
1f3ef54
Rename key-value variables specific to function parameter
guiltiest-gear Oct 5, 2024
23a65d3
fix: hexIndex now increments correct amount
guiltiest-gear Oct 5, 2024
3abd949
refactor(color conversion): separate check logic into function
guiltiest-gear Oct 5, 2024
3567f38
docs(zathura): add comments to document custom table function
guiltiest-gear Oct 5, 2024
f2ef4fe
refactor(color conversion): assign to variables first, then insert
guiltiest-gear Oct 6, 2024
c2e5a23
chore(zathura): remove note comment
guiltiest-gear Oct 6, 2024
93a4587
style(zathura): improve clarity of variable names
guiltiest-gear Oct 6, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 33 additions & 3 deletions lua/tokyonight/extra/zathura.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -45,7 +75,7 @@ set render-loading-bg "${fg}"
set recolor-lightcolor "${bg}"
set recolor-darkcolor "${fg}"
]],
colors
zathuraColors
)
return zathura
end
Expand Down