From ceaf02e0bffe291a1377da907a5f45c78e1593bd Mon Sep 17 00:00:00 2001 From: siduck Date: Sun, 20 Feb 2022 11:44:43 +0530 Subject: [PATCH] replace dashboard with alpha.nvim (#816) --- lua/colors/highlights.lua | 7 ++- lua/core/default_config.lua | 12 +---- lua/core/mappings.lua | 10 ---- lua/plugins/configs/alpha.lua | 86 +++++++++++++++++++++++++++++++ lua/plugins/configs/dashboard.lua | 35 ------------- lua/plugins/configs/others.lua | 2 +- lua/plugins/init.lua | 9 ++-- 7 files changed, 95 insertions(+), 66 deletions(-) create mode 100644 lua/plugins/configs/alpha.lua delete mode 100644 lua/plugins/configs/dashboard.lua diff --git a/lua/colors/highlights.lua b/lua/colors/highlights.lua index 13a142a..1c3dae8 100644 --- a/lua/colors/highlights.lua +++ b/lua/colors/highlights.lua @@ -12,6 +12,7 @@ local folder_bg = colors.folder_bg local green = colors.green local grey = colors.grey local grey_fg = colors.grey_fg +local light_grey = colors.light_grey local line = colors.line local nord_blue = colors.nord_blue local one_bg = colors.one_bg @@ -77,10 +78,8 @@ end -- [[ Plugin Highlights -- Dashboard -fg("DashboardCenter", grey_fg) -fg("DashboardFooter", grey_fg) -fg("DashboardHeader", grey_fg) -fg("DashboardShortcut", grey_fg) +fg("AlphaHeader", grey_fg) +fg("AlphaButtons", light_grey) -- Git signs fg_bg("DiffAdd", blue, "NONE") diff --git a/lua/core/default_config.lua b/lua/core/default_config.lua index 876b93b..8954fa9 100644 --- a/lua/core/default_config.lua +++ b/lua/core/default_config.lua @@ -63,7 +63,7 @@ M.plugins = { bufferline = true, -- manage and preview opened buffers colorizer = false, -- color RGB, HEX, CSS, NAME color codes comment = true, -- easily (un)comment code, language aware - dashboard = false, + alpha = false, -- dashboard better_escape = true, -- map to with no lag feline = true, -- statusline gitsigns = true, @@ -95,9 +95,9 @@ M.plugins = { -- hide, show on specific filetypes hidden = { "help", - "dashboard", "NvimTree", "terminal", + "alpha", }, shown = {}, @@ -182,14 +182,6 @@ M.mappings.plugins = { toggle = "/", }, - dashboard = { - bookmarks = "bm", - new_file = "fn", -- basically create a new buffer - open = "db", -- open dashboard - session_load = "l", - session_save = "s", - }, - -- map to with no lag better_escape = { -- will still work esc_insertmode = { "jk" }, -- multiple mappings allowed diff --git a/lua/core/mappings.lua b/lua/core/mappings.lua index 29557fe..90cd679 100644 --- a/lua/core/mappings.lua +++ b/lua/core/mappings.lua @@ -140,16 +140,6 @@ M.comment = function() map("v", m, ":lua require('Comment.api').toggle_linewise_op(vim.fn.visualmode())") end -M.dashboard = function() - local m = plugin_maps.dashboard - - map("n", m.bookmarks, ":DashboardJumpMarks ") - map("n", m.new_file, ":DashboardNewFile ") - map("n", m.open, ":Dashboard ") - map("n", m.session_load, ":SessionLoad ") - map("n", m.session_save, ":SessionSave ") -end - M.lspconfig = function() local m = plugin_maps.lspconfig diff --git a/lua/plugins/configs/alpha.lua b/lua/plugins/configs/alpha.lua new file mode 100644 index 0000000..7171306 --- /dev/null +++ b/lua/plugins/configs/alpha.lua @@ -0,0 +1,86 @@ +local present, alpha = pcall(require, "alpha") + +if not present then + return +end + +local ascii = { + " ⣴⣶⣤⡤⠦⣤⣀⣤⠆ ⣈⣭⣿⣶⣿⣦⣼⣆ ", + " ⠉⠻⢿⣿⠿⣿⣿⣶⣦⠤⠄⡠⢾⣿⣿⡿⠋⠉⠉⠻⣿⣿⡛⣦ ", + " ⠈⢿⣿⣟⠦ ⣾⣿⣿⣷ ⠻⠿⢿⣿⣧⣄ ", + " ⣸⣿⣿⢧ ⢻⠻⣿⣿⣷⣄⣀⠄⠢⣀⡀⠈⠙⠿⠄ ", + " ⢠⣿⣿⣿⠈ ⣻⣿⣿⣿⣿⣿⣿⣿⣛⣳⣤⣀⣀ ", + " ⢠⣧⣶⣥⡤⢄ ⣸⣿⣿⠘ ⢀⣴⣿⣿⡿⠛⣿⣿⣧⠈⢿⠿⠟⠛⠻⠿⠄ ", + " ⣰⣿⣿⠛⠻⣿⣿⡦⢹⣿⣷ ⢊⣿⣿⡏ ⢸⣿⣿⡇ ⢀⣠⣄⣾⠄ ", + " ⣠⣿⠿⠛ ⢀⣿⣿⣷⠘⢿⣿⣦⡀ ⢸⢿⣿⣿⣄ ⣸⣿⣿⡇⣪⣿⡿⠿⣿⣷⡄ ", + " ⠙⠃ ⣼⣿⡟ ⠈⠻⣿⣿⣦⣌⡇⠻⣿⣿⣷⣿⣿⣿ ⣿⣿⡇ ⠛⠻⢷⣄ ", + " ⢻⣿⣿⣄ ⠈⠻⣿⣿⣿⣷⣿⣿⣿⣿⣿⡟ ⠫⢿⣿⡆ ", + " ⠻⣿⣿⣿⣿⣶⣶⣾⣿⣿⣿⣿⣿⣿⣿⣿⡟⢀⣀⣤⣾⡿⠃ ", +} + +local header = { + type = "text", + val = ascii, + opts = { + position = "center", + hl = "AlphaHeader", + }, +} + +local function button(sc, txt, keybind) + local sc_ = sc:gsub("%s", ""):gsub("SPC", "") + + local opts = { + position = "center", + text = txt, + shortcut = sc, + cursor = 5, + width = 36, + align_shortcut = "right", + hl = "AlphaButtons", + } + + if keybind then + opts.keymap = { "n", sc_, keybind, { noremap = true, silent = true } } + end + + return { + type = "button", + val = txt, + on_press = function() + local key = vim.api.nvim_replace_termcodes(sc_, true, false, true) + vim.api.nvim_feedkeys(key, "normal", false) + end, + opts = opts, + } +end + +local buttons = { + type = "group", + val = { + button("SPC f f", " Find File ", ":Telescope find_files"), + button("SPC f o", " Recent File ", ":Telescope oldfiles"), + button("SPC f w", " Find Word ", ":Telescope live_grep"), + button("SPC b m", " Bookmarks ", ":Telescope marks"), + button("SPC t h", " Themes ", ":Telescope themes"), + button("SPC e s", " Settings", ":e $MYVIMRC | :cd %:p:h "), + }, + opts = { + spacing = 1, + }, +} + +local section = { + header = header, + buttons = buttons, +} + +alpha.setup { + layout = { + { type = "padding", val = 5 }, + section.header, + { type = "padding", val = 2 }, + section.buttons, + }, + opts = {}, +} diff --git a/lua/plugins/configs/dashboard.lua b/lua/plugins/configs/dashboard.lua deleted file mode 100644 index abd93e2..0000000 --- a/lua/plugins/configs/dashboard.lua +++ /dev/null @@ -1,35 +0,0 @@ -local g = vim.g - -g.dashboard_disable_at_vimenter = 0 -g.dashboard_disable_statusline = 1 -g.dashboard_default_executive = "telescope" -g.dashboard_custom_header = { - " ", - " ", - " ", - " ⣴⣶⣤⡤⠦⣤⣀⣤⠆ ⣈⣭⣿⣶⣿⣦⣼⣆ ", - " ⠉⠻⢿⣿⠿⣿⣿⣶⣦⠤⠄⡠⢾⣿⣿⡿⠋⠉⠉⠻⣿⣿⡛⣦ ", - " ⠈⢿⣿⣟⠦ ⣾⣿⣿⣷ ⠻⠿⢿⣿⣧⣄ ", - " ⣸⣿⣿⢧ ⢻⠻⣿⣿⣷⣄⣀⠄⠢⣀⡀⠈⠙⠿⠄ ", - " ⢠⣿⣿⣿⠈ ⣻⣿⣿⣿⣿⣿⣿⣿⣛⣳⣤⣀⣀ ", - " ⢠⣧⣶⣥⡤⢄ ⣸⣿⣿⠘ ⢀⣴⣿⣿⡿⠛⣿⣿⣧⠈⢿⠿⠟⠛⠻⠿⠄ ", - " ⣰⣿⣿⠛⠻⣿⣿⡦⢹⣿⣷ ⢊⣿⣿⡏ ⢸⣿⣿⡇ ⢀⣠⣄⣾⠄ ", - " ⣠⣿⠿⠛ ⢀⣿⣿⣷⠘⢿⣿⣦⡀ ⢸⢿⣿⣿⣄ ⣸⣿⣿⡇⣪⣿⡿⠿⣿⣷⡄ ", - " ⠙⠃ ⣼⣿⡟ ⠈⠻⣿⣿⣦⣌⡇⠻⣿⣿⣷⣿⣿⣿ ⣿⣿⡇ ⠛⠻⢷⣄ ", - " ⢻⣿⣿⣄ ⠈⠻⣿⣿⣿⣷⣿⣿⣿⣿⣿⡟ ⠫⢿⣿⡆ ", - " ⠻⣿⣿⣿⣿⣶⣶⣾⣿⣿⣿⣿⣿⣿⣿⣿⡟⢀⣀⣤⣾⡿⠃ ", - " ", -} - -g.dashboard_custom_section = { - a = { description = { " Find File SPC f f" }, command = "Telescope find_files" }, - b = { description = { " Recents SPC f o" }, command = "Telescope oldfiles" }, - c = { description = { " Find Word SPC f w" }, command = "Telescope live_grep" }, - d = { description = { "洛 New File SPC f n" }, command = "DashboardNewFile" }, - e = { description = { " Bookmarks SPC b m" }, command = "Telescope marks" }, - f = { description = { " Load Last Session SPC l " }, command = "SessionLoad" }, -} - -g.dashboard_custom_footer = { - " ", -} diff --git a/lua/plugins/configs/others.lua b/lua/plugins/configs/others.lua index de9ac85..99877cc 100644 --- a/lua/plugins/configs/others.lua +++ b/lua/plugins/configs/others.lua @@ -32,7 +32,7 @@ M.blankline = function(override_flag) filetype_exclude = { "help", "terminal", - "dashboard", + "alpha", "packer", "lspinfo", "TelescopePrompt", diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index 43177b4..a6f915e 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -182,12 +182,9 @@ local plugins = { }, { - "glepnir/dashboard-nvim", - disable = not plugin_settings.status.dashboard, - config = override_req("dashboard", "plugins.configs.dashboard"), - setup = function() - require("core.mappings").dashboard() - end, + disable = not plugin_settings.status.alpha, + "goolord/alpha-nvim", + config = override_req("alpha", "plugins.configs.alpha"), }, {