diff options
author | Squibid <me@zacharyscheiman.com> | 2025-05-31 03:32:58 -0400 |
---|---|---|
committer | Squibid <me@zacharyscheiman.com> | 2025-05-31 03:32:58 -0400 |
commit | e830931ff421e4380d5de8b1926842000ba9be34 (patch) | |
tree | 207584548026db649bc6ab21df3b41b71ebfd830 /lua/core/color.lua | |
parent | ef678f31fdf24c0e6c4eca9a13ad9f63a53447b9 (diff) | |
download | nvim-master.tar.gz nvim-master.tar.bz2 nvim-master.zip |
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 |