From b42f4778f96a3069ee349be55dd6ec5d5706d915 Mon Sep 17 00:00:00 2001 From: siduck76 Date: Sat, 26 Jun 2021 07:40:23 +0530 Subject: [PATCH] lazy load dashboard --- init.lua | 1 - lua/dashboard.lua | 71 +++++++++++++++++++++++------------------- lua/mappings.lua | 7 +++++ lua/pluginList.lua | 13 +++++++- lua/telescope-nvim.lua | 8 ----- 5 files changed, 58 insertions(+), 42 deletions(-) diff --git a/init.lua b/init.lua index d9f190c..2a83c44 100644 --- a/init.lua +++ b/init.lua @@ -54,5 +54,4 @@ vim.api.nvim_exec( require "zenmode" require "whichkey" -require "dashboard" require("nvim_comment").setup() diff --git a/lua/dashboard.lua b/lua/dashboard.lua index b9dff2a..5fda4c7 100644 --- a/lua/dashboard.lua +++ b/lua/dashboard.lua @@ -1,35 +1,42 @@ -local g = vim.g +local M = {} -g.dashboard_disable_statusline = 1 -g.dashboard_default_executive = "telescope" -g.dashboard_custom_header = { - " ", - " ", - " ", - " ⣴⣶⣤⡤⠦⣤⣀⣤⠆ ⣈⣭⣿⣶⣿⣦⣼⣆ ", - " ⠉⠻⢿⣿⠿⣿⣿⣶⣦⠤⠄⡠⢾⣿⣿⡿⠋⠉⠉⠻⣿⣿⡛⣦ ", - " ⠈⢿⣿⣟⠦ ⣾⣿⣿⣷ ⠻⠿⢿⣿⣧⣄ ", - " ⣸⣿⣿⢧ ⢻⠻⣿⣿⣷⣄⣀⠄⠢⣀⡀⠈⠙⠿⠄ ", - " ⢠⣿⣿⣿⠈ ⣻⣿⣿⣿⣿⣿⣿⣿⣛⣳⣤⣀⣀ ", - " ⢠⣧⣶⣥⡤⢄ ⣸⣿⣿⠘ ⢀⣴⣿⣿⡿⠛⣿⣿⣧⠈⢿⠿⠟⠛⠻⠿⠄ ", - " ⣰⣿⣿⠛⠻⣿⣿⡦⢹⣿⣷ ⢊⣿⣿⡏ ⢸⣿⣿⡇ ⢀⣠⣄⣾⠄ ", - " ⣠⣿⠿⠛ ⢀⣿⣿⣷⠘⢿⣿⣦⡀ ⢸⢿⣿⣿⣄ ⣸⣿⣿⡇⣪⣿⡿⠿⣿⣷⡄ ", - " ⠙⠃ ⣼⣿⡟ ⠈⠻⣿⣿⣦⣌⡇⠻⣿⣿⣷⣿⣿⣿ ⣿⣿⡇ ⠛⠻⢷⣄ ", - " ⢻⣿⣿⣄ ⠈⠻⣿⣿⣿⣷⣿⣿⣿⣿⣿⡟ ⠫⢿⣿⡆ ", - " ⠻⣿⣿⣿⣿⣶⣶⣾⣿⣿⣿⣿⣿⣿⣿⣿⡟⢀⣀⣤⣾⡿⠃ ", - " " -} +M.config = function() + local g = vim.g -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 s l"}, command = "SessionLoad"} -} + g.dashboard_disable_at_vimenter = 1 -- dashboard is disabled by default + g.dashboard_disable_statusline = 1 + g.dashboard_default_executive = "telescope" + g.dashboard_custom_header = { + " ", + " ", + " ", + " ⣴⣶⣤⡤⠦⣤⣀⣤⠆ ⣈⣭⣿⣶⣿⣦⣼⣆ ", + " ⠉⠻⢿⣿⠿⣿⣿⣶⣦⠤⠄⡠⢾⣿⣿⡿⠋⠉⠉⠻⣿⣿⡛⣦ ", + " ⠈⢿⣿⣟⠦ ⣾⣿⣿⣷ ⠻⠿⢿⣿⣧⣄ ", + " ⣸⣿⣿⢧ ⢻⠻⣿⣿⣷⣄⣀⠄⠢⣀⡀⠈⠙⠿⠄ ", + " ⢠⣿⣿⣿⠈ ⣻⣿⣿⣿⣿⣿⣿⣿⣛⣳⣤⣀⣀ ", + " ⢠⣧⣶⣥⡤⢄ ⣸⣿⣿⠘ ⢀⣴⣿⣿⡿⠛⣿⣿⣧⠈⢿⠿⠟⠛⠻⠿⠄ ", + " ⣰⣿⣿⠛⠻⣿⣿⡦⢹⣿⣷ ⢊⣿⣿⡏ ⢸⣿⣿⡇ ⢀⣠⣄⣾⠄ ", + " ⣠⣿⠿⠛ ⢀⣿⣿⣷⠘⢿⣿⣦⡀ ⢸⢿⣿⣿⣄ ⣸⣿⣿⡇⣪⣿⡿⠿⣿⣷⡄ ", + " ⠙⠃ ⣼⣿⡟ ⠈⠻⣿⣿⣦⣌⡇⠻⣿⣿⣷⣿⣿⣿ ⣿⣿⡇ ⠛⠻⢷⣄ ", + " ⢻⣿⣿⣄ ⠈⠻⣿⣿⣿⣷⣿⣿⣿⣿⣿⡟ ⠫⢿⣿⡆ ", + " ⠻⣿⣿⣿⣿⣶⣶⣾⣿⣿⣿⣿⣿⣿⣿⣿⡟⢀⣀⣤⣾⡿⠃ ", + " " + } -g.dashboard_custom_footer = { - " ", - "NvChad v0.5" -} + 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 s l"}, command = "SessionLoad"} + } + + g.dashboard_custom_footer = { + " ", + "NvChad v0.5" + } +end + +return M diff --git a/lua/mappings.lua b/lua/mappings.lua index 5f886c2..cf0fb41 100644 --- a/lua/mappings.lua +++ b/lua/mappings.lua @@ -104,3 +104,10 @@ map( ) map("n", "fm", [[ Neoformat]], opt) + +-- dashboard stuff +map("n", "fw", [[ Telescope live_grep]], opt) +map("n", "fn", [[ DashboardNewFile]], opt) +map("n", "bm", [[ DashboardJumpMarks]], opt) +map("n", "sl", [[ SessionLoad]], opt) +map("n", "ss", [[ SessionSave]], opt) diff --git a/lua/pluginList.lua b/lua/pluginList.lua index ed359ff..486fe7f 100644 --- a/lua/pluginList.lua +++ b/lua/pluginList.lua @@ -83,7 +83,18 @@ return packer.startup( use "nvim-lua/popup.nvim" -- misc - use "glepnir/dashboard-nvim" + use { + "glepnir/dashboard-nvim", + cmd = { + "Telescope live_grep", + "DashboardNewFile", + "DashboardJumpMarks" + }, + setup = function() + require("dashboard").config() + end + } + use "tweekmonster/startuptime.vim" -- load autosave plugin only if its globally enabled diff --git a/lua/telescope-nvim.lua b/lua/telescope-nvim.lua index 7511156..58eebca 100644 --- a/lua/telescope-nvim.lua +++ b/lua/telescope-nvim.lua @@ -68,14 +68,6 @@ vim.api.nvim_set_keymap( [[lua require('telescope').extensions.media_files.media_files()]], opt ) - vim.api.nvim_set_keymap("n", "fb", [[lua require('telescope.builtin').buffers()]], opt) vim.api.nvim_set_keymap("n", "fh", [[lua require('telescope.builtin').help_tags()]], opt) vim.api.nvim_set_keymap("n", "fo", [[lua require('telescope.builtin').oldfiles()]], opt) - --- dashboard stuff -vim.api.nvim_set_keymap("n", "fw", [[ Telescope live_grep]], opt) -vim.api.nvim_set_keymap("n", "fn", [[ DashboardNewFile]], opt) -vim.api.nvim_set_keymap("n", "bm", [[ DashboardJumpMarks]], opt) -vim.api.nvim_set_keymap("n", "sl", [[ SessionLoad]], opt) -vim.api.nvim_set_keymap("n", "ss", [[ SessionSave]], opt)