mirror of
https://github.com/folke/snacks.nvim
synced 2025-08-05 03:08:13 +00:00
feat(util): set_hl managed
This commit is contained in:
parent
b0da066536
commit
96426953a0
1 changed files with 4 additions and 2 deletions
|
@ -15,13 +15,15 @@ vim.api.nvim_create_autocmd("ColorScheme", {
|
|||
|
||||
--- Ensures the hl groups are always set, even after a colorscheme change.
|
||||
---@param groups snacks.util.hl
|
||||
---@param opts? { prefix?:string, default?:boolean }
|
||||
---@param opts? { prefix?:string, default?:boolean, managed?:boolean }
|
||||
function M.set_hl(groups, opts)
|
||||
for hl_group, hl in pairs(groups) do
|
||||
hl_group = opts and opts.prefix and opts.prefix .. hl_group or hl_group
|
||||
hl = type(hl) == "string" and { link = hl } or hl --[[@as vim.api.keyset.highlight]]
|
||||
hl.default = not (opts and opts.default == false)
|
||||
hl_groups[hl_group] = hl
|
||||
if not (opts and opts.managed == false) then
|
||||
hl_groups[hl_group] = hl
|
||||
end
|
||||
vim.api.nvim_set_hl(0, hl_group, hl)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue