diff --git a/lua/lazyvim/plugins/extras/ui/alpha.lua b/lua/lazyvim/plugins/extras/ui/alpha.lua new file mode 100644 index 00000000..38019498 --- /dev/null +++ b/lua/lazyvim/plugins/extras/ui/alpha.lua @@ -0,0 +1,77 @@ +return { + + { "glepnir/dashboard-nvim", enabled = false }, + { "echasnovski/mini.starter", enabled = false }, + -- Dashboard. This runs when neovim starts, and is what displays + -- the "LAZYVIM" banner. + { + "goolord/alpha-nvim", + event = "VimEnter", + enabled = true, + init = false, + opts = function() + local dashboard = require("alpha.themes.dashboard") + local logo = [[ + ██╗ █████╗ ███████╗██╗ ██╗██╗ ██╗██╗███╗ ███╗ Z + ██║ ██╔══██╗╚══███╔╝╚██╗ ██╔╝██║ ██║██║████╗ ████║ Z + ██║ ███████║ ███╔╝ ╚████╔╝ ██║ ██║██║██╔████╔██║ z + ██║ ██╔══██║ ███╔╝ ╚██╔╝ ╚██╗ ██╔╝██║██║╚██╔╝██║ z + ███████╗██║ ██║███████╗ ██║ ╚████╔╝ ██║██║ ╚═╝ ██║ + ╚══════╝╚═╝ ╚═╝╚══════╝ ╚═╝ ╚═══╝ ╚═╝╚═╝ ╚═╝ + ]] + + dashboard.section.header.val = vim.split(logo, "\n") + dashboard.section.buttons.val = { + dashboard.button("f", " " .. " Find file", " Telescope find_files "), + dashboard.button("n", " " .. " New file", " ene startinsert "), + dashboard.button("r", " " .. " Recent files", " Telescope oldfiles "), + dashboard.button("g", " " .. " Find text", " Telescope live_grep "), + dashboard.button("c", " " .. " Config", " e $MYVIMRC "), + dashboard.button("s", " " .. " Restore Session", [[ lua require("persistence").load() ]]), + dashboard.button("l", "󰒲 " .. " Lazy", " Lazy "), + dashboard.button("q", " " .. " Quit", " qa "), + } + 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 = 8 + 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, + }, +} diff --git a/lua/lazyvim/plugins/extras/ui/dashboard.lua b/lua/lazyvim/plugins/extras/ui/dashboard.lua deleted file mode 100644 index 2c678f36..00000000 --- a/lua/lazyvim/plugins/extras/ui/dashboard.lua +++ /dev/null @@ -1,64 +0,0 @@ -return { - { "goolord/alpha-nvim", enabled = false }, - { "echasnovski/mini.starter", enabled = false }, - { - "glepnir/dashboard-nvim", - event = "VimEnter", - opts = function() - local logo = [[ - ██╗ █████╗ ███████╗██╗ ██╗██╗ ██╗██╗███╗ ███╗ Z - ██║ ██╔══██╗╚══███╔╝╚██╗ ██╔╝██║ ██║██║████╗ ████║ Z - ██║ ███████║ ███╔╝ ╚████╔╝ ██║ ██║██║██╔████╔██║ z - ██║ ██╔══██║ ███╔╝ ╚██╔╝ ╚██╗ ██╔╝██║██║╚██╔╝██║ z - ███████╗██║ ██║███████╗ ██║ ╚████╔╝ ██║██║ ╚═╝ ██║ - ╚══════╝╚═╝ ╚═╝╚══════╝ ╚═╝ ╚═══╝ ╚═╝╚═╝ ╚═╝ - ]] - - logo = string.rep("\n", 8) .. logo .. "\n\n" - - local opts = { - theme = "doom", - hide = { - -- this is taken care of by lualine - -- enabling this messes up the actual laststatus setting after loading a file - statusline = false, - }, - config = { - header = vim.split(logo, "\n"), - center = { - { action = "Telescope find_files", desc = " Find file", icon = " ", key = "f" }, - { action = "ene | startinsert", desc = " New file", icon = " ", key = "n" }, - { action = "Telescope oldfiles", desc = " Recent files", icon = " ", key = "r" }, - { action = "Telescope live_grep", desc = " Find text", icon = " ", key = "g" }, - { action = "e $MYVIMRC", desc = " Config", icon = " ", key = "c" }, - { action = 'lua require("persistence").load()', desc = " Restore Session", icon = " ", key = "s" }, - { action = "Lazy", desc = " Lazy", icon = "󰒲 ", key = "l" }, - { action = "qa", desc = " Quit", icon = " ", key = "q" }, - }, - footer = function() - local stats = require("lazy").stats() - local ms = (math.floor(stats.startuptime * 100 + 0.5) / 100) - return { "⚡ Neovim loaded " .. stats.loaded .. "/" .. stats.count .. " plugins in " .. ms .. "ms" } - end, - }, - } - - for _, button in ipairs(opts.config.center) do - button.desc = button.desc .. string.rep(" ", 43 - #button.desc) - end - - -- 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", { - pattern = "DashboardLoaded", - callback = function() - require("lazy").show() - end, - }) - end - - return opts - end, - }, -} diff --git a/lua/lazyvim/plugins/ui.lua b/lua/lazyvim/plugins/ui.lua index f1bac031..9cb5237b 100644 --- a/lua/lazyvim/plugins/ui.lua +++ b/lua/lazyvim/plugins/ui.lua @@ -155,7 +155,11 @@ return { cond = function () return package.loaded["dap"] and require("dap").status() ~= "" end, color = Util.ui.fg("Debug"), }, - { require("lazy.status").updates, cond = require("lazy.status").has_updates, color = Util.ui.fg("Special") }, + { + require("lazy.status").updates, + cond = require("lazy.status").has_updates, + color = Util.ui.fg("Special"), + }, { "diff", symbols = { @@ -295,77 +299,6 @@ return { }, }, - -- Dashboard. This runs when neovim starts, and is what displays - -- the "LAZYVIM" banner. - { - "goolord/alpha-nvim", - event = "VimEnter", - opts = function() - local dashboard = require("alpha.themes.dashboard") - local logo = [[ - ██╗ █████╗ ███████╗██╗ ██╗██╗ ██╗██╗███╗ ███╗ Z - ██║ ██╔══██╗╚══███╔╝╚██╗ ██╔╝██║ ██║██║████╗ ████║ Z - ██║ ███████║ ███╔╝ ╚████╔╝ ██║ ██║██║██╔████╔██║ z - ██║ ██╔══██║ ███╔╝ ╚██╔╝ ╚██╗ ██╔╝██║██║╚██╔╝██║ z - ███████╗██║ ██║███████╗ ██║ ╚████╔╝ ██║██║ ╚═╝ ██║ - ╚══════╝╚═╝ ╚═╝╚══════╝ ╚═╝ ╚═══╝ ╚═╝╚═╝ ╚═╝ - ]] - - dashboard.section.header.val = vim.split(logo, "\n") - dashboard.section.buttons.val = { - dashboard.button("f", " " .. " Find file", " Telescope find_files "), - dashboard.button("n", " " .. " New file", " ene startinsert "), - dashboard.button("r", " " .. " Recent files", " Telescope oldfiles "), - dashboard.button("g", " " .. " Find text", " Telescope live_grep "), - dashboard.button("c", " " .. " Config", " e $MYVIMRC "), - dashboard.button("s", " " .. " Restore Session", [[ lua require("persistence").load() ]]), - dashboard.button("l", "󰒲 " .. " Lazy", " Lazy "), - dashboard.button("q", " " .. " Quit", " qa "), - } - 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 = 8 - 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, - }, - -- lsp symbol navigation for lualine. This shows where -- in the code structure you are - within functions, classes, -- etc - in the statusline. @@ -396,4 +329,78 @@ return { -- ui components { "MunifTanjim/nui.nvim", lazy = true }, + + { + "goolord/alpha-nvim", + optional = true, + enabled = function() + require("lazyvim.util").warn({ + "`dashboard.nvim` is now the default LazyVim starter plugin.", + "", + "To keep using `alpha.nvim`, please enable the `lazyvim.plugins.extras.ui.alpha` extra.", + "Or to hide this message, remove the alpha spec from your config.", + }) + return false + end, + }, + { + "glepnir/dashboard-nvim", + event = "VimEnter", + opts = function() + local logo = [[ + ██╗ █████╗ ███████╗██╗ ██╗██╗ ██╗██╗███╗ ███╗ Z + ██║ ██╔══██╗╚══███╔╝╚██╗ ██╔╝██║ ██║██║████╗ ████║ Z + ██║ ███████║ ███╔╝ ╚████╔╝ ██║ ██║██║██╔████╔██║ z + ██║ ██╔══██║ ███╔╝ ╚██╔╝ ╚██╗ ██╔╝██║██║╚██╔╝██║ z + ███████╗██║ ██║███████╗ ██║ ╚████╔╝ ██║██║ ╚═╝ ██║ + ╚══════╝╚═╝ ╚═╝╚══════╝ ╚═╝ ╚═══╝ ╚═╝╚═╝ ╚═╝ + ]] + + logo = string.rep("\n", 8) .. logo .. "\n\n" + + local opts = { + theme = "doom", + hide = { + -- this is taken care of by lualine + -- enabling this messes up the actual laststatus setting after loading a file + statusline = false, + }, + config = { + header = vim.split(logo, "\n"), + center = { + { action = "Telescope find_files", desc = " Find file", icon = " ", key = "f" }, + { action = "ene | startinsert", desc = " New file", icon = " ", key = "n" }, + { action = "Telescope oldfiles", desc = " Recent files", icon = " ", key = "r" }, + { action = "Telescope live_grep", desc = " Find text", icon = " ", key = "g" }, + { action = "e $MYVIMRC", desc = " Config", icon = " ", key = "c" }, + { action = 'lua require("persistence").load()', desc = " Restore Session", icon = " ", key = "s" }, + { action = "Lazy", desc = " Lazy", icon = "󰒲 ", key = "l" }, + { action = "qa", desc = " Quit", icon = " ", key = "q" }, + }, + footer = function() + local stats = require("lazy").stats() + local ms = (math.floor(stats.startuptime * 100 + 0.5) / 100) + return { "⚡ Neovim loaded " .. stats.loaded .. "/" .. stats.count .. " plugins in " .. ms .. "ms" } + end, + }, + } + + for _, button in ipairs(opts.config.center) do + button.desc = button.desc .. string.rep(" ", 43 - #button.desc) + end + + -- 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", { + pattern = "DashboardLoaded", + callback = function() + require("lazy").show() + end, + }) + end + + return opts + end, + }, } diff --git a/lua/lazyvim/util/plugin.lua b/lua/lazyvim/util/plugin.lua index a9d6ccd2..ca6a162b 100644 --- a/lua/lazyvim/util/plugin.lua +++ b/lua/lazyvim/util/plugin.lua @@ -11,6 +11,7 @@ M.lazy_file_events = { "BufReadPost", "BufNewFile", "BufWritePre" } M.deprecated_extras = { ["lazyvim.plugins.extras.formatting.conform"] = "`conform.nvim` is now the default **LazyVim** formatter.", ["lazyvim.plugins.extras.linting.nvim-lint"] = "`nvim-lint` is now the default **LazyVim** linter.", + ["lazyvim.plugins.extras.ui.dashboard"] = "`dashboard.nvim` is now the default **LazyVim** starter.", } ---@type table