From e4b78b22099c607acffdf717c3bda343f0221945 Mon Sep 17 00:00:00 2001 From: wires Date: Sat, 8 Mar 2025 12:20:46 -0500 Subject: [PATCH] session stuff + new dashboard --- lazy-lock.json | 2 +- lua/editor.lua | 1 + lua/plugins/alpha.lua | 5 ++ lua/plugins/alpha/theme.lua | 109 ++++++++++++++++++++++++++ lua/plugins/auto-session/init.lua | 4 +- lua/plugins/auto-session/mappings.lua | 8 +- lua/plugins/which-key.lua | 21 +++-- 7 files changed, 127 insertions(+), 23 deletions(-) create mode 100644 lua/plugins/alpha.lua create mode 100644 lua/plugins/alpha/theme.lua diff --git a/lazy-lock.json b/lazy-lock.json index d0d5e8a..cf98ca3 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -2,6 +2,7 @@ "Comment.nvim": { "branch": "master", "commit": "e30b7f2008e52442154b66f7c519bfd2f1e32acb" }, "LuaSnip": { "branch": "master", "commit": "c9b9a22904c97d0eb69ccb9bab76037838326817" }, "SchemaStore.nvim": { "branch": "main", "commit": "b6ee84c6db9c8d557e0c8b71f1b6800e77611771" }, + "alpha-nvim": { "branch": "main", "commit": "de72250e054e5e691b9736ee30db72c65d560771" }, "auto-session": { "branch": "main", "commit": "9c3f977aafb56bd73ba0d082c4dcbdba5666faf3" }, "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, "cmp-cmdline": { "branch": "main", "commit": "d250c63aa13ead745e3a40f61fdd3470efde3923" }, @@ -35,7 +36,6 @@ "telescope-fzf-native.nvim": { "branch": "main", "commit": "2a5ceff981501cff8f46871d5402cd3378a8ab6a" }, "telescope.nvim": { "branch": "master", "commit": "814f102cd1da3dc78c7d2f20f2ef3ed3cdf0e6e4" }, "todo-comments.nvim": { "branch": "main", "commit": "304a8d204ee787d2544d8bc23cd38d2f929e7cc5" }, - "tokyonight.nvim": { "branch": "main", "commit": "057ef5d260c1931f1dffd0f052c685dcd14100a3" }, "trouble.nvim": { "branch": "main", "commit": "85bedb7eb7fa331a2ccbecb9202d8abba64d37b3" }, "vim-eunuch": { "branch": "master", "commit": "e86bb794a1c10a2edac130feb0ea590a00d03f1e" }, "vim-fugitive": { "branch": "master", "commit": "4a745ea72fa93bb15dd077109afbb3d1809383f2" }, diff --git a/lua/editor.lua b/lua/editor.lua index 9f47d27..4341e81 100644 --- a/lua/editor.lua +++ b/lua/editor.lua @@ -22,6 +22,7 @@ opt.clipboard = 'unnamedplus' opt.encoding = 'utf-8' opt.matchpairs = { '(:)', '{:}', '[:]', '<:>' } opt.syntax = 'enable' +opt.sessionoptions = 'blank,buffers,curdir,folds,help,tabpages,winsize,winpos,terminal,localoptions' -- indention opt.autoindent = true diff --git a/lua/plugins/alpha.lua b/lua/plugins/alpha.lua new file mode 100644 index 0000000..dd1b4a5 --- /dev/null +++ b/lua/plugins/alpha.lua @@ -0,0 +1,5 @@ +return { + 'goolord/alpha-nvim', + opts = require('plugins.alpha.theme'), + lazy = false, +} diff --git a/lua/plugins/alpha/theme.lua b/lua/plugins/alpha/theme.lua new file mode 100644 index 0000000..41fc934 --- /dev/null +++ b/lua/plugins/alpha/theme.lua @@ -0,0 +1,109 @@ +local if_nil = vim.F.if_nil + +local default_terminal = { + type = 'terminal', + command = nil, + width = 69, + height = 8, + opts = { + redraw = true, + window_config = {}, + }, +} + +local default_header = { + type = 'text', + val = { + [[ __]], + [[ ___ ___ ___ __ __ /\_\ ___ ___]], + [[ / _ `\ / __`\ / __`\/\ \/\ \\/\ \ / __` __`\]], + [[ /\ \/\ \/\ __//\ \_\ \ \ \_/ |\ \ \/\ \/\ \/\ \]], + [[ \ \_\ \_\ \____\ \____/\ \___/ \ \_\ \_\ \_\ \_\]], + [[ \/_/\/_/\/____/\/___/ \/__/ \/_/\/_/\/_/\/_/]], + }, + opts = { + position = 'center', + hl = 'Type', + -- wrap = "overflow"; + }, +} + +local footer = { + type = 'text', + val = '', + opts = { + position = 'center', + hl = 'Number', + }, +} + +local leader = 'SPC' + +--- @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, '') + + local opts = { + position = 'center', + shortcut = sc, + cursor = 3, + width = 50, + 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_ .. '', true, false, true) + vim.api.nvim_feedkeys(key, 't', false) + end + + return { + type = 'button', + val = txt, + on_press = on_press, + opts = opts, + } +end + +local buttons = { + type = 'group', + val = { + button('SPC f f', '󰈞 Find file'), + button('SPC f s', ' Find word'), + button('SPC s l', ' Open last session'), + }, + opts = { + spacing = 1, + }, +} + +local section = { + terminal = default_terminal, + header = default_header, + buttons = buttons, + footer = footer, +} + +local content_height = #section.header.val + #section.buttons.val * 2 + 1 + +local config = { + layout = { + { type = 'padding', val = vim.fn.floor((vim.fn.winheight(0) - content_height) / 2) }, + section.header, + { type = 'padding', val = 2 }, + section.buttons, + section.footer, + }, + opts = { + margin = 5, + }, +} + +return config diff --git a/lua/plugins/auto-session/init.lua b/lua/plugins/auto-session/init.lua index 1b9edbc..50465c4 100644 --- a/lua/plugins/auto-session/init.lua +++ b/lua/plugins/auto-session/init.lua @@ -1,7 +1,5 @@ local config = { - auto_restore = true, - auto_session = true, - enabled = true, + auto_restore = false, pre_save_cmds = { 'cclose', 'lua vim.notify.dismiss()' }, } diff --git a/lua/plugins/auto-session/mappings.lua b/lua/plugins/auto-session/mappings.lua index d5e36f1..4b998da 100644 --- a/lua/plugins/auto-session/mappings.lua +++ b/lua/plugins/auto-session/mappings.lua @@ -1,11 +1,5 @@ local map = require('utils').set_keymap -- session -map('n', 'sl', 'silent RestoreSession', { desc = 'Restore session' }) +map('n', 'sl', 'silent SessionRestore', { desc = 'Restore session' }) map('n', 'ss', 'SaveSession', { desc = 'Save session' }) -map( - 'n', - 'si', - 'lua require("utils.logger"):log("Session name: " .. require("auto-session-library").current_session_name())', - { desc = 'Print session' } -) diff --git a/lua/plugins/which-key.lua b/lua/plugins/which-key.lua index 65c2bc9..e45b7a0 100644 --- a/lua/plugins/which-key.lua +++ b/lua/plugins/which-key.lua @@ -21,23 +21,20 @@ return { }) wk.add({ - { 'c', group = 'quickfix' }, - { 'f', group = 'find' }, - { 'g', group = 'goto' }, - { 'h', group = 'gitsigns' }, + { 'c', group = 'quickfix' }, + { 'f', group = 'find' }, { 'ht', group = 'toggle' }, - { 'k', group = 'buffer' }, - { 'l', group = 'lsp' }, + { 'k', group = 'buffer' }, + { 'l', group = 'lsp' }, { 'ld', group = 'diagnostics' }, { 'lt', group = 'toggle' }, { 'lw', group = 'workspace' }, - { 'n', group = 'tree' }, - { 'p', group = 'lazy (plugins)' }, - { 's', group = 'session' }, - { 't', group = 'tab' }, - { 'v', group = 'git (vsc)' }, + { 'p', group = 'lazy (plugins)' }, + { 's', group = 'session' }, + { 't', group = 'tab' }, + { 'v', group = 'git (vsc)' }, { 'vt', group = 'toggle' }, - { 'x', group = 'terminal' }, + { 'x', group = 'trouble' }, }) end, event = 'VeryLazy',