mirror of
https://github.com/folke/snacks.nvim
synced 2025-08-07 12:18:10 +00:00
feat(dashboard): add dashboard startuptime icon option (#214)
## Description Adds an `icon` option to the dashboard `startup` section. So people (like me, who thinks an emoji in a bunch of nerdfonts is awkward) can change it easily. ## Screenshots <details> <summary>Screenshots</summary> Screenshot with a minimal config  </details> --------- Co-authored-by: Folke Lemaitre <folke.lemaitre@gmail.com>
This commit is contained in:
parent
20a19dfaa8
commit
63506d5168
3 changed files with 9 additions and 4 deletions
|
@ -708,8 +708,9 @@ installed.
|
||||||
Add the startup section
|
Add the startup section
|
||||||
|
|
||||||
>lua
|
>lua
|
||||||
|
---@param opts? {icon?:string}
|
||||||
---@return snacks.dashboard.Section?
|
---@return snacks.dashboard.Section?
|
||||||
Snacks.dashboard.sections.startup()
|
Snacks.dashboard.sections.startup(opts)
|
||||||
<
|
<
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -639,8 +639,9 @@ Snacks.dashboard.sections.session(item)
|
||||||
Add the startup section
|
Add the startup section
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
|
---@param opts? {icon?:string}
|
||||||
---@return snacks.dashboard.Section?
|
---@return snacks.dashboard.Section?
|
||||||
Snacks.dashboard.sections.startup()
|
Snacks.dashboard.sections.startup(opts)
|
||||||
```
|
```
|
||||||
|
|
||||||
### `Snacks.dashboard.sections.terminal()`
|
### `Snacks.dashboard.sections.terminal()`
|
||||||
|
|
|
@ -1060,14 +1060,17 @@ function M.sections.terminal(opts)
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Add the startup section
|
--- Add the startup section
|
||||||
|
---@param opts? {icon?:string}
|
||||||
---@return snacks.dashboard.Section?
|
---@return snacks.dashboard.Section?
|
||||||
function M.sections.startup()
|
function M.sections.startup(opts)
|
||||||
|
opts = opts or {}
|
||||||
M.lazy_stats = M.lazy_stats and M.lazy_stats.startuptime > 0 and M.lazy_stats or require("lazy.stats").stats()
|
M.lazy_stats = M.lazy_stats and M.lazy_stats.startuptime > 0 and M.lazy_stats or require("lazy.stats").stats()
|
||||||
local ms = (math.floor(M.lazy_stats.startuptime * 100 + 0.5) / 100)
|
local ms = (math.floor(M.lazy_stats.startuptime * 100 + 0.5) / 100)
|
||||||
|
local icon = opts.icon or "⚡ "
|
||||||
return {
|
return {
|
||||||
align = "center",
|
align = "center",
|
||||||
text = {
|
text = {
|
||||||
{ "⚡ Neovim loaded ", hl = "footer" },
|
{ icon .. "Neovim loaded ", hl = "footer" },
|
||||||
{ M.lazy_stats.loaded .. "/" .. M.lazy_stats.count, hl = "special" },
|
{ M.lazy_stats.loaded .. "/" .. M.lazy_stats.count, hl = "special" },
|
||||||
{ " plugins in ", hl = "footer" },
|
{ " plugins in ", hl = "footer" },
|
||||||
{ ms .. "ms", hl = "special" },
|
{ ms .. "ms", hl = "special" },
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue