Something went wrong. Try again.
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121local alpha = require("alpha")local fortune = require("alpha.fortune")
local header = { type = "text", val = { [[ ███╗ ██╗███████╗ ██████╗ ██╗ ██╗██╗███╗ ███╗ ]], [[ ████╗ ██║██╔════╝██╔═══██╗██║ ██║██║████╗ ████║ ]], [[ ██╔██╗ ██║█████╗ ██║ ██║██║ ██║██║██╔████╔██║ ]], [[ ██║╚██╗██║██╔══╝ ██║ ██║╚██╗ ██╔╝██║██║╚██╔╝██║ ]], [[ ██║ ╚████║███████╗╚██████╔╝ ╚████╔╝ ██║██║ ╚═╝ ██║ ]], [[ ╚═╝ ╚═══╝╚══════╝ ╚═════╝ ╚═══╝ ╚═╝╚═╝ ╚═╝ ]], }, opts = { position = "center", hl = "Identifier", },}
local footer = { type = "text", val = fortune(), opts = { position = "center", hl = "Constant", },}
local plugin_stats = { type = "text", val = {}, opts = { position = "center", hl = "Comment", },}
local leader = "<Leader>"
--- @param shortcut string--- @param text string--- @param action? string--- @param keymap_opts? tablelocal function button(shortcut, text, action, keymap_opts) local key = shortcut:gsub("%s", ""):gsub(leader, "<leader>")
local opts = { position = "center", shortcut = shortcut, cursor = 5, width = 50, align_shortcut = "right", hl_shortcut = "Type", }
if action then keymap_opts = keymap_opts or { noremap = true, silent = true, nowait = true } opts.keymap = { "n", key, action, keymap_opts } end
local function on_press() local key = vim.api.nvim_replace_termcodes(key .. "<Ignore>", true, false, true) vim.api.nvim_feedkeys(key, "t", false) end
return { type = "button", val = text, on_press = on_press, opts = opts, }end
local buttons = { type = "group", val = { button("e", " Empty File", "<Cmd>ene <CR>"), button("f", " Find File", "<Cmd>Telescope find_files<CR>"), button("g", " Live Grep", "<Cmd>Telescope live_grep<CR>"), button("o", " Recently Opened Files", "<Cmd>Telescope oldfiles only_cwd=true<CR>"), button("p", " Plugins", "<Cmd>Lazy<CR>"), button("q", "✖ Quit", "<Cmd>q<CR>"), }, opts = { spacing = 1, },}
local section = { header = header, buttons = buttons, footer = footer,}
local config = { layout = { { type = "padding", val = 2 }, section.header, { type = "padding", val = 2 }, section.buttons, section.footer, plugin_stats, }, opts = { margin = 5, },}
alpha.setup(config)
vim.api.nvim_create_autocmd("User", { pattern = "LazyVimStarted", callback = function() local stats = require("lazy").stats() local ms = (math.floor(stats.startuptime * 100 + 0.5) / 100) table.insert(plugin_stats.val, "") table.insert(plugin_stats.val, "[⚡ loaded " .. stats.count .. " plugins in " .. ms .. "ms]") pcall(vim.cmd.AlphaRedraw) end,})