Skip to content

Commit af17342

Browse files
Shrub24sphamba
authored andcommitted
added support for highlight groups as colour
1 parent 382bdc3 commit af17342

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

lua/smear_cursor/color.lua

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,12 @@ function M.clear_cache()
8888
cache = {}
8989
end
9090

91+
local function resolve_color(str)
92+
if not str then return nil end
93+
if str:match("^#") then return str end
94+
return get_hl_color(str, "bg")
95+
end
96+
9197
function M.get_color_at_cursor()
9298
local cursor = vim.api.nvim_win_get_cursor(0)
9399
cursor[1] = cursor[1] - 1
@@ -115,7 +121,8 @@ end
115121
---@param opts? {level?: number, inverted?: boolean}
116122
function M.get_hl_group(opts)
117123
opts = opts or {}
118-
local _cursor_color = (vim.api.nvim_get_mode().mode == "i") and C.cursor_color_insert_mode or C.cursor_color
124+
local _cursor_color = (vim.api.nvim_get_mode().mode == "i") and resolve_color(C.cursor_color_insert_mode)
125+
or resolve_color(C.cursor_color)
119126

120127
local hl_group = ("SmearCursor%s%s"):format(opts.inverted and "Inverted" or "", tostring(opts.level or ""))
121128

0 commit comments

Comments
 (0)