mirror of
https://github.com/DefectingCat/nvim
synced 2025-07-15 08:41:33 +00:00
80 lines
2.2 KiB
Lua
80 lines
2.2 KiB
Lua
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, "<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_ .. "<Ignore>", 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", "<cmd>Lazy<CR>"),
|
|
button("SPC e", " > Nvim Tree", "<cmd>NvimTreeToggle<CR>"),
|
|
button("SPC m", " > Mason", "<cmd>Mason<CR>"),
|
|
-- button("SPC fw", " > Find Word", "<cmd>Telescope live_grep<CR>"),
|
|
button("SPC wr", " > Restore Session", "<cmd>SessionRestore<CR>"),
|
|
button("q", " > Quit", "<cmd>qa<CR>"),
|
|
}
|
|
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,
|
|
}
|