---@alias snacks.util.hl table<string, string|vim.api.keyset.highlight>
---@param fg string foreground color
---@param bg string background color
---@param alpha number number between 0 and 1. 0 results in bg, 1 results in fg
Snacks.util.blend(fg, bg, alpha)
Set buffer-local options.
---@param buf number
---@param bo vim.bo
Snacks.util.bo(buf, bo)
---@param group string hl group to get color from
---@param prop? string property to get. Defaults to "fg"
Snacks.util.color(group, prop)
Decodes a file name to a string.
---@param str string
Snacks.util.file_decode(str)
Encodes a string to be used as a file name.
---@param str string
Snacks.util.file_encode(str)
Get an icon from mini.icons
or nvim-web-devicons
.
---@param name string
---@param cat? string defaults to "file"
---@return string, string?
Snacks.util.icon(name, cat)
Check if the colorscheme is transparent.
Snacks.util.is_transparent()
---@param str string
Snacks.util.keycode(str)
---@param key string
---@param cb fun(key:string)
Snacks.util.on_key(key, cb)
Call a function when a module is loaded. The callback is called immediately if the module is already loaded. Otherwise, it is called when the module is loaded.
---@param modname string
---@param cb fun(modname:string)
Snacks.util.on_module(modname, cb)
Redraw the window. Optimized for Neovim >= 0.10
---@param win number
Snacks.util.redraw(win)
Redraw the range of lines in the window. Optimized for Neovim >= 0.10
---@param win number
---@param from number -- 1-indexed, inclusive
---@param to number -- 1-indexed, inclusive
Snacks.util.redraw_range(win, from, to)
---@generic T
---@param t T
---@return { value?:T }|fun():T?
Snacks.util.ref(t)
Ensures the hl groups are always set, even after a colorscheme change.
---@param groups snacks.util.hl
---@param opts? { prefix?:string, default?:boolean, managed?:boolean }
Snacks.util.set_hl(groups, opts)
---@generic T
---@param fn T
---@param opts? {ms?:number}
---@return T
Snacks.util.throttle(fn, opts)
Get a buffer or global variable.
---@generic T
---@param buf? number
---@param name string
---@param default? T
---@return T
Snacks.util.var(buf, name, default)
Set window-local options.
---@param win number
---@param wo vim.wo
Snacks.util.wo(win, wo)