summaryrefslogtreecommitdiffstats
path: root/after/plugin/startpage.lua
blob: 2f12e566273cc7b68680bd10b8828fc43a2c28ab (plain) (blame)
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
local status_ok, alpha = pcall(require, "alpha")
if not status_ok then
	return
end

-- buttons
local function button(sc, txt, keybind)
  local opts = {
    position = "center",
    shortcut = sc,
    cursor = 5,
    width = 80,
    align_shortcut = "right",
    hl_shortcut = "Keyword",
  }
  local function on_press()
    local key = vim.api.nvim_replace_termcodes(keybind .. "<Ignore>", true, false, true)
    vim.api.nvim_feedkeys(key, "t", false)
  end

  return {
    type = "button",
    val = txt,
    on_press = on_press,
    opts = opts,
  }
end

-- actual config
local R = {}

R.width = vim.api.nvim_win_get_width(0)
R.height = vim.api.nvim_win_get_height(0)

if R.width >= 120 then
  alpha.setup {
    layout = {
      { type = "padding", val = math.floor(R.height / 2.5) },
      button([[        `'::.                         `'::::.          ]], "Recent Files", "<cmd>Telescope oldfiles<CR>"),
      button([[    _________H ,%%&%,                   _____A_        ]], "New File", "<cmd>ene<CR>"),
      button([[   /\     _   \%&&%%&%                 /      /\       ]], "Update Plugins", "<cmd>DepSync<CR>"),
      button([[  /  \___/^\___\%&%%&&              __/__/\__/  \___   ]], "", ""),
      button([[  |  | []   [] |%\Y&%'             /__|" '' "| /___/\  ]], "", ""),
      button([[  |  |   .-.   | ||                |''|"'||'"| |' '||  ]], "", ""),
      button([[~~@._|@@_|||_@@|~||~~~            ~`""`""))""`"`""""`~~]], "", ""),
      button([[     `""") )"""`                        //             ]], "", ""),
    }
  }
end
if R.width <= 119 then
  local header = {
    [[        `'::.                         `'::::.          ]],
    [[    _________H ,%%&%,                   _____A_        ]],
    [[   /\     _   \%&&%%&%                 /      /\       ]],
    [[  /  \___/^\___\%&%%&&              __/__/\__/  \___   ]],
    [[  |  | []   [] |%\Y&%'             /__|" '' "| /___/\  ]],
    [[  |  |   .-.   | ||                |''|"'||'"| |' '||  ]],
    [[~~@._|@@_|||_@@|~||~~~            ~`""`""))""`"`""""`~~]],
    [[     `""") )"""`                        //             ]],
  }
  alpha.setup {
    layout = {
      { type = "padding", val = math.floor(R.height / 2.5)  },
      { type = "text", val = header, opts = { position = "center", hl = "AlphaHeader" } },
      { type = "padding", val = 1  },
      button([[]], "Recent Files", "<cmd>Telescope oldfiles<CR>"),
      button([[]], "New File", "<cmd>ene<CR>"),
      button([[]], "Update Plugins", "<cmd>DepSync<CR>"),
    }
  }
end