mirror of
https://github.com/LazyVim/LazyVim.git
synced 2026-07-25 14:01:06 +00:00
feat(ui): add dashboard animation
This commit is contained in:
parent
f9dadc11b3
commit
22c0046e7c
1 changed files with 57 additions and 6 deletions
|
|
@ -279,16 +279,67 @@ return {
|
||||||
event = "VimEnter",
|
event = "VimEnter",
|
||||||
opts = function()
|
opts = function()
|
||||||
local dashboard = require("alpha.themes.dashboard")
|
local dashboard = require("alpha.themes.dashboard")
|
||||||
local logo = [[
|
local interval_ms = 700
|
||||||
██╗ █████╗ ███████╗██╗ ██╗██╗ ██╗██╗███╗ ███╗ Z
|
local frame_index = 1
|
||||||
██║ ██╔══██╗╚══███╔╝╚██╗ ██╔╝██║ ██║██║████╗ ████║ Z
|
local frames = {
|
||||||
██║ ███████║ ███╔╝ ╚████╔╝ ██║ ██║██║██╔████╔██║ z
|
[[
|
||||||
|
██╗ █████╗ ███████╗██╗ ██╗██╗ ██╗██╗███╗ ███╗
|
||||||
|
██║ ██╔══██╗╚══███╔╝╚██╗ ██╔╝██║ ██║██║████╗ ████║
|
||||||
|
██║ ███████║ ███╔╝ ╚████╔╝ ██║ ██║██║██╔████╔██║
|
||||||
██║ ██╔══██║ ███╔╝ ╚██╔╝ ╚██╗ ██╔╝██║██║╚██╔╝██║ z
|
██║ ██╔══██║ ███╔╝ ╚██╔╝ ╚██╗ ██╔╝██║██║╚██╔╝██║ z
|
||||||
███████╗██║ ██║███████╗ ██║ ╚████╔╝ ██║██║ ╚═╝ ██║
|
███████╗██║ ██║███████╗ ██║ ╚████╔╝ ██║██║ ╚═╝ ██║
|
||||||
╚══════╝╚═╝ ╚═╝╚══════╝ ╚═╝ ╚═══╝ ╚═╝╚═╝ ╚═╝
|
╚══════╝╚═╝ ╚═╝╚══════╝ ╚═╝ ╚═══╝ ╚═╝╚═╝ ╚═╝
|
||||||
]]
|
]],
|
||||||
|
[[
|
||||||
|
██╗ █████╗ ███████╗██╗ ██╗██╗ ██╗██╗███╗ ███╗
|
||||||
|
██║ ██╔══██╗╚══███╔╝╚██╗ ██╔╝██║ ██║██║████╗ ████║
|
||||||
|
██║ ███████║ ███╔╝ ╚████╔╝ ██║ ██║██║██╔████╔██║ z
|
||||||
|
██║ ██╔══██║ ███╔╝ ╚██╔╝ ╚██╗ ██╔╝██║██║╚██╔╝██║
|
||||||
|
███████╗██║ ██║███████╗ ██║ ╚████╔╝ ██║██║ ╚═╝ ██║
|
||||||
|
╚══════╝╚═╝ ╚═╝╚══════╝ ╚═╝ ╚═══╝ ╚═╝╚═╝ ╚═╝
|
||||||
|
]],
|
||||||
|
[[
|
||||||
|
██╗ █████╗ ███████╗██╗ ██╗██╗ ██╗██╗███╗ ███╗
|
||||||
|
██║ ██╔══██╗╚══███╔╝╚██╗ ██╔╝██║ ██║██║████╗ ████║ Z
|
||||||
|
██║ ███████║ ███╔╝ ╚████╔╝ ██║ ██║██║██╔████╔██║
|
||||||
|
██║ ██╔══██║ ███╔╝ ╚██╔╝ ╚██╗ ██╔╝██║██║╚██╔╝██║
|
||||||
|
███████╗██║ ██║███████╗ ██║ ╚████╔╝ ██║██║ ╚═╝ ██║
|
||||||
|
╚══════╝╚═╝ ╚═╝╚══════╝ ╚═╝ ╚═══╝ ╚═╝╚═╝ ╚═╝
|
||||||
|
]],
|
||||||
|
[[
|
||||||
|
██╗ █████╗ ███████╗██╗ ██╗██╗ ██╗██╗███╗ ███╗ Z
|
||||||
|
██║ ██╔══██╗╚══███╔╝╚██╗ ██╔╝██║ ██║██║████╗ ████║
|
||||||
|
██║ ███████║ ███╔╝ ╚████╔╝ ██║ ██║██║██╔████╔██║
|
||||||
|
██║ ██╔══██║ ███╔╝ ╚██╔╝ ╚██╗ ██╔╝██║██║╚██╔╝██║
|
||||||
|
███████╗██║ ██║███████╗ ██║ ╚████╔╝ ██║██║ ╚═╝ ██║
|
||||||
|
╚══════╝╚═╝ ╚═╝╚══════╝ ╚═╝ ╚═══╝ ╚═╝╚═╝ ╚═╝
|
||||||
|
]],
|
||||||
|
}
|
||||||
|
-- Function to update the header with the next frame
|
||||||
|
local function update_header()
|
||||||
|
dashboard.section.header.val = vim.split(frames[frame_index], "\n")
|
||||||
|
frame_index = (frame_index % #frames) + 1
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Init
|
||||||
|
update_header()
|
||||||
|
|
||||||
|
-- Start timer to update the header
|
||||||
|
local timer_id = vim.fn.timer_start(interval_ms, function()
|
||||||
|
update_header()
|
||||||
|
pcall(vim.cmd.AlphaRedraw)
|
||||||
|
end, { ["repeat"] = -1 })
|
||||||
|
|
||||||
|
-- end timer when Dashboard is closed
|
||||||
|
vim.api.nvim_create_autocmd("User", {
|
||||||
|
pattern = "AlphaClosed",
|
||||||
|
callback = function()
|
||||||
|
if timer_id then
|
||||||
|
vim.fn.timer_stop(timer_id)
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
dashboard.section.header.val = vim.split(logo, "\n")
|
|
||||||
dashboard.section.buttons.val = {
|
dashboard.section.buttons.val = {
|
||||||
dashboard.button("f", " " .. " Find file", ":Telescope find_files <CR>"),
|
dashboard.button("f", " " .. " Find file", ":Telescope find_files <CR>"),
|
||||||
dashboard.button("n", " " .. " New file", ":ene <BAR> startinsert <CR>"),
|
dashboard.button("n", " " .. " New file", ":ene <BAR> startinsert <CR>"),
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue