From 966d12ac730c83da90d60ab24eae539b2ea69441 Mon Sep 17 00:00:00 2001 From: srdusr Date: Wed, 24 Sep 2025 00:14:04 +0200 Subject: Update/Overhaul --- lua/plugins/dashboard.lua | 114 ++++++++++++++++++++++++++++++---------------- 1 file changed, 75 insertions(+), 39 deletions(-) mode change 100644 => 100755 lua/plugins/dashboard.lua (limited to 'lua/plugins/dashboard.lua') diff --git a/lua/plugins/dashboard.lua b/lua/plugins/dashboard.lua old mode 100644 new mode 100755 index f02242c..43a3461 --- a/lua/plugins/dashboard.lua +++ b/lua/plugins/dashboard.lua @@ -1,11 +1,31 @@ -local db = require('dashboard') -local messages = require('plugins.messages') +local M = {} -function GetRandomMessage() - -- Get a random index from the messages array - local randomIndex = math.random(1, #messages) - return messages[randomIndex] -end +--- Setup and configure dashboard.nvim +-- This function initializes and configures the dashboard plugin +-- @return boolean True if setup was successful, false otherwise +function M.setup() + local ok, db = pcall(require, 'dashboard') + if not ok then + return false + end + + local messages = { + "The only way to do great work is to love what you do. - Steve Jobs", + "Code is like humor. When you have to explain it, it's bad. - Cory House", + "First, solve the problem. Then, write the code. - John Johnson", + "Any fool can write code that a computer can understand. Good programmers write code that humans can understand. - Martin Fowler", + "The most disastrous thing that you can ever learn is your first programming language. - Alan Kay", + "The most important property of a program is whether it accomplishes the intention of its user. - C.A.R. Hoare", + "The best error message is the one that never shows up. - Thomas Fuchs", + "The most important skill for a programmer is the ability to effectively communicate ideas. - Gastón Jorquera", + "The only way to learn a new programming language is by writing programs in it. - Dennis Ritchie", + "The most damaging phrase in the language is 'We've always done it this way!' - Grace Hopper" + } + + local function get_random_message() + local random_index = math.random(1, #messages) + return messages[random_index] + end --vim.api.nvim_create_autocmd("VimEnter", { -- callback = function() @@ -16,10 +36,11 @@ end -- end, --}) -db.setup({ - theme = 'hyper', + -- Configure dashboard + db.setup({ + theme = "hyper", config = { - mru = { limit = 10, label = '' }, + mru = { limit = 20, label = "" }, project = { limit = 10 }, header = { [[ ███╗ ██╗ ███████╗ ██████╗ ██╗ ██╗ ██╗ ███╗ ███╗]], @@ -31,46 +52,47 @@ db.setup({ }, disable_move = false, shortcut = { - { desc = ' Plugins', group = 'Number', action = 'PackerStatus', key = 'p' }, - --{ desc = " Plugins", group = "@property", action = "PackerStatus", key = "p" }, + { desc = " Plugins", group = "Number", action = "PackerStatus", key = "p" }, + { + desc = " Files", + group = "Number", + action = "Telescope find_files", + key = "f", + }, { - desc = ' Files', - group = 'Number', - --group = "Label", - action = 'Telescope find_files', - key = 'f', + desc = " TODO", + group = "Number", + action = ":edit ~/documents/main/inbox/tasks/TODO.md", + key = "t", }, { - desc = ' Text', - group = 'Number', - --group = "Label", - action = 'enew', - key = 't', + desc = " New", + group = "Number", + action = "enew", + key = "e", }, { - desc = ' Grep', - group = 'Number', - --group = "Label", - action = 'Telescope live_grep', - key = 'g', + desc = " Grep", + group = "Number", + action = "Telescope live_grep", + key = "g", }, { - desc = ' Scheme', - group = 'Number', - --group = "Label", - action = 'Telescope colorscheme', - key = 's', + desc = " Scheme", + group = "Number", + action = "Telescope colorscheme", + key = "s", }, { - desc = ' Config', - group = 'Number', - --group = "Label", - action = ':edit ~/.config/nvim/init.lua', - key = 'c', + desc = " Config", + group = "Number", + action = ":edit ~/.config/nvim/init.lua", + key = "c", }, }, footer = function() - return { '', GetRandomMessage() } + return { "", "" } + --return { "", GetRandomMessage() } end, }, hide = { @@ -80,7 +102,16 @@ db.setup({ }, }) ---highlights +-- Set keymaps only when dashboard is active +vim.api.nvim_create_autocmd("FileType", { + group = vim.api.nvim_create_augroup("DashboardMappings", { clear = true }), + pattern = "dashboard", + callback = function() + vim.keymap.set("n", "e", "DashboardNewFile", { buffer = true }) + vim.keymap.set("n", "q", "q!", { buffer = true }) + vim.keymap.set("n", "", "", { buffer = true }) -- Allow Ctrl + o to act normally + end, +}) ---- General --DashboardHeader DashboardFooter ---- Hyper theme @@ -88,3 +119,8 @@ db.setup({ --DashboardMruTitle DashboardMruIcon DashboardFiles DashboardShotCutIcon ---- Doome theme --DashboardDesc DashboardKey DashboardIcon DashboardShotCut + + return true +end + +return M -- cgit v1.2.3