nvim: add get_hl_hex()

This commit is contained in:
tastytea 2022-08-18 17:39:35 +02:00
parent 4abb52dcab
commit 4647ded04d
Signed by: tastytea
SSH Key Fingerprint: SHA256:FBkvrOlhq5use1XEttyUGT4bUTDVA1ar9SgIc9P03cM

View File

@ -93,4 +93,17 @@ function M.shell_capture(command)
return result
end
-- return colours from highlight groups in web notation (#rrggbb)
function M.get_hl_hex(hl_group)
local hl = vim.api.nvim_get_hl_by_name(hl_group, true)
local hl_hex = {}
if hl.foreground then
hl_hex.foreground = string.format('#%.6x', hl.foreground)
end
if hl.background then
hl_hex.background = string.format('#%.6x', hl.background)
end
return hl_hex
end
return M