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

![Snipaste_2024-12-07_22-08-42](https://github.com/user-attachments/assets/bf8c4754-3902-412d-83dc-f7efec77ee7f)

</details>

---------

Co-authored-by: Folke Lemaitre <folke.lemaitre@gmail.com>
This commit is contained in:
SueXY 2024-12-12 05:50:04 +00:00 committed by GitHub
parent 20a19dfaa8
commit 63506d5168
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 9 additions and 4 deletions

View file

@ -708,8 +708,9 @@ installed.
Add the startup section
>lua
---@param opts? {icon?:string}
---@return snacks.dashboard.Section?
Snacks.dashboard.sections.startup()
Snacks.dashboard.sections.startup(opts)
<

View file

@ -639,8 +639,9 @@ Snacks.dashboard.sections.session(item)
Add the startup section
```lua
---@param opts? {icon?:string}
---@return snacks.dashboard.Section?
Snacks.dashboard.sections.startup()
Snacks.dashboard.sections.startup(opts)
```
### `Snacks.dashboard.sections.terminal()`

View file

@ -1060,14 +1060,17 @@ function M.sections.terminal(opts)
end
--- Add the startup section
---@param opts? {icon?:string}
---@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()
local ms = (math.floor(M.lazy_stats.startuptime * 100 + 0.5) / 100)
local icon = opts.icon or ""
return {
align = "center",
text = {
{ "Neovim loaded ", hl = "footer" },
{ icon .. "Neovim loaded ", hl = "footer" },
{ M.lazy_stats.loaded .. "/" .. M.lazy_stats.count, hl = "special" },
{ " plugins in ", hl = "footer" },
{ ms .. "ms", hl = "special" },