mirror of
https://github.com/folke/snacks.nvim
synced 2025-08-04 18:58:12 +00:00
docs(util): added docs
This commit is contained in:
parent
f2135f2fe2
commit
e99b41c175
2 changed files with 19 additions and 6 deletions
14
docs/util.md
14
docs/util.md
|
@ -21,6 +21,8 @@ Snacks.util.blend(fg, bg, alpha)
|
|||
|
||||
### `Snacks.util.bo()`
|
||||
|
||||
Set buffer-local options.
|
||||
|
||||
```lua
|
||||
---@param buf number
|
||||
---@param bo vim.bo
|
||||
|
@ -30,8 +32,8 @@ Snacks.util.bo(buf, bo)
|
|||
### `Snacks.util.color()`
|
||||
|
||||
```lua
|
||||
---@param group string
|
||||
---@param prop? string
|
||||
---@param group string hl group to get color from
|
||||
---@param prop? string property to get. Defaults to "fg"
|
||||
Snacks.util.color(group, prop)
|
||||
```
|
||||
|
||||
|
@ -55,15 +57,19 @@ Snacks.util.file_encode(str)
|
|||
|
||||
### `Snacks.util.icon()`
|
||||
|
||||
Get an icon from `mini.icons` or `nvim-web-devicons`.
|
||||
|
||||
```lua
|
||||
---@param name string
|
||||
---@param cat? string
|
||||
---@param cat? string defaults to "file"
|
||||
---@return string, string?
|
||||
Snacks.util.icon(name, cat)
|
||||
```
|
||||
|
||||
### `Snacks.util.is_transparent()`
|
||||
|
||||
Check if the colorscheme is transparent.
|
||||
|
||||
```lua
|
||||
Snacks.util.is_transparent()
|
||||
```
|
||||
|
@ -102,6 +108,8 @@ Snacks.util.set_hl(groups, opts)
|
|||
|
||||
### `Snacks.util.wo()`
|
||||
|
||||
Set window-local options.
|
||||
|
||||
```lua
|
||||
---@param win number
|
||||
---@param wo vim.wo
|
||||
|
|
|
@ -33,14 +33,15 @@ function M.set_hl(groups, opts)
|
|||
end
|
||||
end
|
||||
|
||||
---@param group string
|
||||
---@param prop? string
|
||||
---@param group string hl group to get color from
|
||||
---@param prop? string property to get. Defaults to "fg"
|
||||
function M.color(group, prop)
|
||||
prop = prop or "fg"
|
||||
local hl = vim.api.nvim_get_hl(0, { name = group, link = false })
|
||||
return hl[prop] and string.format("#%06x", hl[prop])
|
||||
end
|
||||
|
||||
--- Set window-local options.
|
||||
---@param win number
|
||||
---@param wo vim.wo
|
||||
function M.wo(win, wo)
|
||||
|
@ -49,6 +50,7 @@ function M.wo(win, wo)
|
|||
end
|
||||
end
|
||||
|
||||
--- Set buffer-local options.
|
||||
---@param buf number
|
||||
---@param bo vim.bo
|
||||
function M.bo(buf, bo)
|
||||
|
@ -57,8 +59,9 @@ function M.bo(buf, bo)
|
|||
end
|
||||
end
|
||||
|
||||
--- Get an icon from `mini.icons` or `nvim-web-devicons`.
|
||||
---@param name string
|
||||
---@param cat? string
|
||||
---@param cat? string defaults to "file"
|
||||
---@return string, string?
|
||||
function M.icon(name, cat)
|
||||
local try = {
|
||||
|
@ -116,6 +119,8 @@ function M.blend(fg, bg, alpha)
|
|||
end
|
||||
|
||||
local transparent ---@type boolean?
|
||||
|
||||
--- Check if the colorscheme is transparent.
|
||||
function M.is_transparent()
|
||||
if transparent == nil then
|
||||
transparent = M.color("Normal", "bg") == nil
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue