From f68c101f97e5c120ac1c571d91c92e995caba80d Mon Sep 17 00:00:00 2001 From: rootiest Date: Fri, 23 Aug 2024 10:00:29 -0400 Subject: [PATCH] feat: add custom dashboard logo and update buttons in Alpha plugin --- lua/plugins/alpha.lua | 79 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 lua/plugins/alpha.lua diff --git a/lua/plugins/alpha.lua b/lua/plugins/alpha.lua new file mode 100644 index 0000000..32b7a49 --- /dev/null +++ b/lua/plugins/alpha.lua @@ -0,0 +1,79 @@ +-- ╭─────────────────────────────────────────────────────────╮ +-- │ ALPHA │ +-- ╰─────────────────────────────────────────────────────────╯ + +return { + "goolord/alpha-nvim", + event = "VimEnter", + enabled = true, + init = false, + opts = function() + local dashboard = require("alpha.themes.dashboard") + local logo = [[ +██████╗ ██████╗ ██████╗ ████████╗██╗███████╗███████╗████████╗ ███╗ ██╗██╗ ██╗██╗███╗ ███╗ +██╔══██╗██╔═══██╗██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝╚══██╔══╝ ████╗ ██║██║ ██║██║████╗ ████║ +██████╔╝██║ ██║██║ ██║ ██║ ██║█████╗ ███████╗ ██║ ██╔██╗ ██║██║ ██║██║██╔████╔██║ +██╔══██╗██║ ██║██║ ██║ ██║ ██║██╔══╝ ╚════██║ ██║  ██║╚██╗██║╚██╗ ██╔╝██║██║╚██╔╝██║ +██║ ██║╚██████╔╝╚██████╔╝ ██║ ██║███████╗███████║ ██║ ██║ ╚████║ ╚████╔╝ ██║██║ ╚═╝ ██║ +╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚══════╝ ╚═╝ ╚═╝ ╚═══╝ ╚═══╝ ╚═╝╚═╝ ╚═╝ +]] + + dashboard.section.header.val = vim.split(logo, "\n") + -- stylua: ignore start + dashboard.section.buttons.val = { + ---@diagnostic disable: param-type-mismatch + dashboard.button("f", " " .. " Find file", LazyVim.pick()), + dashboard.button("n", " " .. " New file", [[ ene startinsert ]]), + dashboard.button("r", " " .. " Recent files", LazyVim.pick("oldfiles")), + dashboard.button("g", " " .. " Grep text", LazyVim.pick("live_grep")), + dashboard.button("z", " " .. " LazyGit", " LazyGit "), + dashboard.button("c", " " .. " Config", LazyVim.pick.config_files()), + dashboard.button("s", " " .. " Restore Session", [[ lua require("persistence").load() ]]), + dashboard.button("S", "󰢹 " .. " Remote Session", [[ lua require("config.rootiest").load_remote() ]]), + dashboard.button("l", "󰒲 " .. " Lazy", " Lazy "), + dashboard.button("q", " " .. " Quit", " qa "), + } + -- stylua: ignore end + for _, button in ipairs(dashboard.section.buttons.val) do + button.opts.hl = "AlphaButtons" + button.opts.hl_shortcut = "AlphaShortcut" + end + dashboard.section.header.opts.hl = "AlphaHeader" + dashboard.section.buttons.opts.hl = "AlphaButtons" + dashboard.section.footer.opts.hl = "AlphaFooter" + dashboard.opts.layout[1].val = 10 + return dashboard + end, + config = function(_, dashboard) + -- close Lazy and re-open when the dashboard is ready + if vim.o.filetype == "lazy" then + vim.cmd.close() + vim.api.nvim_create_autocmd("User", { + once = true, + pattern = "AlphaReady", + callback = function() + require("lazy").show() + end, + }) + end + + require("alpha").setup(dashboard.opts) + + vim.api.nvim_create_autocmd("User", { + once = true, + pattern = "LazyVimStarted", + callback = function() + local stats = require("lazy").stats() + local ms = (math.floor(stats.startuptime * 100 + 0.5) / 100) + dashboard.section.footer.val = "⚡ Neovim loaded " + .. stats.loaded + .. "/" + .. stats.count + .. " plugins in " + .. ms + .. "ms" + pcall(vim.cmd.AlphaRedraw) + end, + }) + end, +}