diff options
Diffstat (limited to 'lua/core/color.lua')
-rw-r--r-- | lua/core/color.lua | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/lua/core/color.lua b/lua/core/color.lua new file mode 100644 index 0000000..c4525f5 --- /dev/null +++ b/lua/core/color.lua @@ -0,0 +1,26 @@ +local M = {} + +--- copy highlight group +---@param hlgroup string highlight group to copy +---@param namespace? number highlight space +---@return table +function M.copyhl(hlgroup, namespace) + namespace = namespace or 0 + + local ok, hl = pcall(vim.api.nvim_get_hl, namespace, { + name = hlgroup, + create = false + }) + if not ok then + return {} + end + + for _, key in pairs({ "foreground", "background", "special" }) do + if hl[key] then + hl[key] = string.format("#%06x", hl[key]) + end + end + return hl +end + +return M |