Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions lua/nordic/tests/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ assert_eq({ U.hex_to_rgb('#191D24') }, { 25, 29, 36 }, 'U.hex_to_rgb("#191D24")
assert_eq(U.rgb_to_hex(25, 29, 36), '#191D24', 'U.rgb_to_hex(25, 29, 36) should return "#191D24"')
assert_eq(U.rgb_to_hex(5, 6, 9), '#050609', 'U.rgb_to_hex(5, 6, 9) should return "#050609"')
assert_eq(U.blend('#FFFFFF', '#000000', 0.5), '#808080', 'U.blend("#FFFFFF", "#000000", 0.5) should return "#808080"')
assert_eq(U.hexify(0), '#000000', 'U.hexify(0) should return "#000000"')
assert_eq(U.hexify(12542314), '#BF616A', 'U.hexify(12542314) should return "#BF616A"')

assert_eq(
U.removeHash({ red = '#ff0000', green = '#00ff00', blue = { base = '#0000ff', other = '0000fb' } }),
Expand Down
18 changes: 9 additions & 9 deletions lua/nordic/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ function M.apply_highlights(groups)
end
end

function M.get_highlight(group)
local function hexify(value)
if type(value) == 'number' then
return string.format('#%X', value)
elseif type(value) == 'table' then
return vim.tbl_map(hexify, value)
end
return value
function M.hexify(value)
if type(value) == 'number' then
return string.format('#%06X', value)
elseif type(value) == 'table' then
return vim.tbl_map(M.hexify, value)
end
return value
end

return hexify(vim.api.nvim_get_hl(0, { name = group, create = false }))
function M.get_highlight(group)
return M.hexify(vim.api.nvim_get_hl(0, { name = group, create = false }))
end

function M.none()
Expand Down