1
0
Fork 1
Dotfiles_nvim/lua/editor/dashboard.lua

137 lines
5.9 KiB
Lua

return {
'goolord/alpha-nvim',
dependencies = {
'nvim-tree/nvim-web-devicons',
},
config = function()
-- Setup --
local alpha = require('alpha')
local SECTIONS = {}
-- Header --
SECTIONS.header = {
type = 'text',
opts = {
position = 'center',
hl = 'DashboardHeader',
},
val = {
[[ ]],
[[ ]],
[[ ]],
[[ ]],
[[ ██ ]],
[[ ████ ██████ ████ ██ ]],
[[ ███████████ ████ ████  ]],
[[ █████████ ████████ ████ ████ ██ ████████ ]],
[[ █████████ ███ ██████████████ █████ █████████████ ]],
[[ █████████ ██████████ ██████████ █████ █████ ████ ████ ]],
[[ ███████████ ███ ███ ██████████ █████ █████ ████ ████ ]],
[[ ██████ ██████████████████████ █████ █████ █████ ████ ████ ]],
[[ ]],
[[ ]],
[[ ]],
},
}
SECTIONS.sessions = {
type = 'group',
val = function()
local session_rows = {}
local session_utils = require('session_manager.utils')
local sessions = session_utils.get_sessions()
table.sort(
sessions,
function(a, b) return a.dir.filename < b.dir.filename end
)
local line_len = 0
for i = 1, #sessions, 1 do
local len = string.len(sessions[i].dir.filename)
if len > line_len then
line_len = len
end
end
for i = 1, #sessions, 1 do
local session_name = sessions[i].dir.filename
local home_dir = os.getenv('HOME')
session_name = vim.fn.substitute(
session_name,
'^' .. home_dir .. '/Downloads',
'󰇚',
''
)
session_name = vim.fn.substitute(
session_name,
'^' .. home_dir .. '/Workspace/Learning',
'󰑴 ',
''
)
session_name = vim.fn.substitute(
session_name,
'^' .. home_dir .. '/Workspace/AdventOfCode',
'',
''
)
session_name = vim.fn.substitute(
session_name,
'^' .. home_dir .. '/Workspace/School',
'',
''
)
session_name = vim.fn.substitute(
session_name,
'^' .. home_dir .. '/Workspace',
'',
''
)
session_name = vim.fn.substitute(
session_name,
'^' .. home_dir,
'',
''
)
local start_session = function()
session_utils.load_session(sessions[i].filename, false)
end
local row = {
type = 'button',
val = ' ' .. session_name,
on_press = start_session,
opts = {
keymap = { 'n', tostring(i), start_session },
shortcut = string.format('[%d]', i),
align_shortcut = 'left',
hl_shortcut = 'DashboardKey',
position = 'center',
cursor = 1,
width = line_len + 5,
},
}
table.insert(session_rows, row)
end
return session_rows
end,
}
local theme = {
layout = {
{ type = 'padding', val = 2 },
SECTIONS.header,
{ type = 'padding', val = 2 },
SECTIONS.sessions,
},
opts = {
margin = 5,
},
}
alpha.setup(theme)
end,
}