local leader = "SPC" local if_nil = vim.F.if_nil --- @param sc string --- @param txt string --- @param keybind string? optional --- @param keybind_opts table? optional local function button(sc, txt, keybind, keybind_opts) local sc_ = sc:gsub("%s", ""):gsub(leader, "") local opts = { position = "center", shortcut = sc, cursor = 3, width = 40, align_shortcut = "right", hl_shortcut = "Keyword", } if keybind then keybind_opts = if_nil(keybind_opts, { noremap = true, silent = true, nowait = true }) opts.keymap = { "n", sc_, keybind, keybind_opts } end local function on_press() local key = vim.api.nvim_replace_termcodes(keybind or sc_ .. "", true, false, true) vim.api.nvim_feedkeys(key, "t", false) end return { type = "button", val = txt, on_press = on_press, opts = opts, } end return { "goolord/alpha-nvim", event = "VimEnter", config = function() local alpha = require("alpha") local dashboard = require("alpha.themes.dashboard") local logo = require("rua.config.logos") dashboard.section.header.val = logo.c dashboard.section.buttons.val = { button("SPC l", "💤 > Lazy", "Lazy"), button("SPC e", " > Nvim Tree", "NvimTreeToggle"), button("SPC m", "󰱼 > Mason", "Mason"), -- button("SPC fw", " > Find Word", "Telescope live_grep"), button("SPC wr", "󰁯 > Restore Session", "SessionRestore"), button("q", " > Quit", "qa"), } dashboard.opts.layout[1].val = 8 -- Send config to alpha alpha.setup(dashboard.opts) -- Disable folding on alpha buffer vim.cmd([[autocmd FileType alpha setlocal nofoldenable]]) 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, }