summaryrefslogtreecommitdiff
path: root/.config/nvim/lua/custom/plugins/alpha.lua
blob: fa0740cd945abcb9671ebbcea53af34bc1b6cc2c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
return {
    'goolord/alpha-nvim',
    dependencies = { 'nvim-tree/nvim-web-devicons' },
    event = function()
        if vim.fn.argc() == 0 then
            return 'VimEnter'
        end
    end,
    config = function()
        local alpha = require('alpha')
        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 = {
            [[                                                                     ]],
            [[       ████ ██████           █████  ██ ██                     ]],
            [[      ███████████             █████ ███                          ]],
            [[      █████████ ███████████████████ ███   ███████████   ]],
            [[     █████████  ███    █████████████ █████ ██████████████   ]],
            [[    █████████ ██████████ █████████ █████ █████ ████ █████   ]],
            [[  ███████████ ███    ███ █████████ █████ █████ ████ █████  ]],
            [[ ██████  █████████████████████ ████ █████ █████ ████ ██████ ]],
            [[                                                                       ]],
            info_line,
        }

        dashboard.section.buttons.opts.spacing = 0
        dashboard.section.buttons.val = {
            dashboard.button('e', '  > New file', '<cmd>ene <BAR> startinsert<cr>'),
            dashboard.button('f', '  > Find file', '<cmd>cd ' .. find_file_path .. ' | Telescope find_files<cr>'),
            dashboard.button('r', '  > Recent', '<cmd>Telescope oldfiles<cr>'),
            dashboard.button('c', '  > Configuration', '<cmd>e $MYVIMRC<cr> | <cmd>cd %:p:h<cr>'),
            -- FIX: doesn't seem to work so great, probably just use a project manager
            -- will most likely make my own project manager plugin
            -- dashboard.button(
            --     's',
            --     '󱎠  > Last Session',
            --     '<cmd>lua require("auto-session.session-lens.actions").alternate_session()<cr>'
            -- ),
            dashboard.button('q', '󰈆  > Quit NVIM', '<cmd>qa<cr>'),
        }

        dashboard.section.footer.val = require('alpha.fortune')()

        alpha.setup(dashboard.opts)
    end,
}