From 52e447a66cd0ff01c7906a6ebea0b06e84959b2c Mon Sep 17 00:00:00 2001 From: Kyren223 Date: Fri, 5 Jul 2024 18:59:51 +0300 Subject: Neovim: configured alpha.nvim start screen --- .config/nvim/lua/plugins/alpha.lua | 66 ++++++++++++++++++++++---------------- 1 file changed, 39 insertions(+), 27 deletions(-) (limited to '.config') diff --git a/.config/nvim/lua/plugins/alpha.lua b/.config/nvim/lua/plugins/alpha.lua index 2489703..ffef9d4 100644 --- a/.config/nvim/lua/plugins/alpha.lua +++ b/.config/nvim/lua/plugins/alpha.lua @@ -1,18 +1,40 @@ return { - -- TODO: Customize this or maybe use dashboard.nvim 'goolord/alpha-nvim', dependencies = { 'nvim-tree/nvim-web-devicons', }, config = function() local alpha = require('alpha') - local dashboard = require('alpha.themes.startify') + local dashboard = require('alpha.themes.dashboard') + + local function get_natural_day(day) + local suffix = 'th' + local day_mod = day % 10 + + if day_mod == 1 and day ~= 11 then + suffix = 'st' + elseif day_mod == 2 and day ~= 12 then + suffix = 'nd' + elseif day_mod == 3 and day ~= 13 then + suffix = 'rd' + end + + return tostring(day) .. suffix + end + + local find_file_path = '$HOME' + local date = os.date('  %A, %B ') .. get_natural_day(tonumber(os.date('%d'))) + local plugins = '  ' .. require('lazy').stats().count .. ' plugins ' + local v = vim.version() + local version = '  v' .. v.major .. '.' .. v.minor .. '.' .. v.patch + local info_line = date .. plugins .. version + + -- WARN: Just hardcoded the length of the first line in the header + local header_length = #'  ' + local padding = (header_length - #info_line) / 2 + info_line = string.rep(' ', padding) .. info_line dashboard.section.header.val = { - [[ ]], - [[ ]], - [[ ]], - [[ ]], [[  ]], [[ ████ ██████ █████ ██ ██ ]], [[ ███████████ █████ ███ ]], @@ -22,29 +44,19 @@ return { [[ ███████████ ███ ███ █████████ █████ █████ ████ █████ ]], [[ ██████ █████████████████████ ████ █████ █████ ████ ██████ ]], [[ ]], - [[ ]], - [[ ]], + info_line, + } + + dashboard.section.buttons.opts.spacing = 0 + dashboard.section.buttons.val = { + dashboard.button('e', ' > New file', 'ene startinsert'), + dashboard.button('w', ' > Find file', 'cd ' .. find_file_path .. ' | Telescope find_files'), + dashboard.button('r', ' > Recent', 'Telescope oldfiles'), + dashboard.button('c', ' > Configuration', 'e $MYVIMRC | cd %:p:h'), + dashboard.button('q', '󰈆 > Quit NVIM', 'qa'), } - --[=[ - dashboard.section.header.val = { - [[ ]], - [[ ]], - [[ ]], - [[ ]], - [[ ]], - [[ ████ ███ ]], - [[ █████████ ]], - [[ ██████████ ████████ ████████ ]], - [[ ██████████ ███ ███ ███ ]], - [[ ████████ ████████ ███ ███ ]], - [[ █████████ ███ ███ ███ ]], - [[ ██████ ███ █████████ ███ ███ ]], - [[ ]], - [[ ]], - [[ ]], - } - ]=] + dashboard.section.footer.val = require('alpha.fortune')() alpha.setup(dashboard.opts) end, -- cgit v1.3.1