irongit

A readme explaining how to make neovim work fast

hygo-vim/lua/plugins/alpha.lua
71 lines2.6 KBLua
1return {
2 {
3 "goolord/alpha-nvim",
4 event = "VimEnter",
5 enabled = true,
6 init = false,
7 opts = function()
8 local dashboard = require("alpha.themes.dashboard")
9 local logo_path = vim.fn.stdpath("config") .. "/logo.txt"
10 local logo = {}
11 for line in io.lines(logo_path) do
12 table.insert(logo, line)
13 end
14
15 dashboard.section.header.val = logo
16 dashboard.section.buttons.val = {
17 dashboard.button("f", "" .. " Find file", "<cmd> lua LazyVim.pick()() <cr>"),
18 dashboard.button("n", "" .. " New file", [[<cmd> ene <BAR> startinsert <cr>]]),
19 dashboard.button("r", "" .. " Recent files", [[<cmd> lua LazyVim.pick("oldfiles")() <cr>]]),
20 dashboard.button("g", "" .. " Find text", [[<cmd> lua LazyVim.pick("live_grep")() <cr>]]),
21 dashboard.button("c", "" .. " Config", "<cmd> lua LazyVim.pick.config_files()() <cr>"),
22 dashboard.button("s", "" .. " Restore Session", [[<cmd> lua require("persistence").load() <cr>]]),
23 dashboard.button("x", "" .. " Lazy Extras", "<cmd> LazyExtras <cr>"),
24 dashboard.button("l", "󰒲 " .. " Lazy", "<cmd> Lazy <cr>"),
25 dashboard.button("z", "" .. " LeetCode", "<cmd> Leet <cr>"),
26 dashboard.button("q", "" .. " Quit", "<cmd> qa <cr>"),
27 }
28 for _, button in ipairs(dashboard.section.buttons.val) do
29 button.opts.hl = "AlphaButtons"
30 button.opts.hl_shortcut = "AlphaShortcut"
31 end
32 dashboard.section.header.opts.hl = "AlphaHeader"
33 dashboard.section.buttons.opts.hl = "AlphaButtons"
34 dashboard.section.footer.opts.hl = "AlphaFooter"
35 dashboard.opts.layout[1].val = 8
36 return dashboard
37 end,
38 config = function(_, dashboard)
39 -- close Lazy and re-open when the dashboard is ready
40 if vim.o.filetype == "lazy" then
41 vim.cmd.close()
42 vim.api.nvim_create_autocmd("User", {
43 once = true,
44 pattern = "AlphaReady",
45 callback = function()
46 require("lazy").show()
47 end,
48 })
49 end
50
51 require("alpha").setup(dashboard.opts)
52
53 vim.api.nvim_create_autocmd("User", {
54 once = true,
55 pattern = "LazyVimStarted",
56 callback = function()
57 local stats = require("lazy").stats()
58 local ms = (math.floor(stats.startuptime * 100 + 0.5) / 100)
59 dashboard.section.footer.val = "⚡ Neovim loaded "
60 .. stats.loaded
61 .. "/"
62 .. stats.count
63 .. " plugins in "
64 .. ms
65 .. "ms"
66 pcall(vim.cmd.AlphaRedraw)
67 end,
68 })
69 end,
70 },
71}