-
-
Notifications
You must be signed in to change notification settings - Fork 194
/
Copy pathdashboard.lua
79 lines (67 loc) · 2.05 KB
/
dashboard.lua
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
74
75
76
77
78
79
local api = vim.api
local db = require('dashboard')
local db_session = require('dashboard.session')
local dashboard_start = api.nvim_create_augroup('dashboard_start', { clear = true })
api.nvim_create_autocmd('Vimenter', {
group = dashboard_start,
nested = true,
callback = function()
if vim.fn.argc() == 0 and vim.fn.line2byte('$') == -1 and not db.disable_at_vimenter then
db:instance(true)
end
end,
})
api.nvim_create_autocmd('FileType', {
group = dashboard_start,
pattern = 'dashboard',
callback = function()
if db.hide_statusline then
vim.opt.laststatus = 0
end
if db.hide_tabline then
vim.opt.showtabline = 0
end
if vim.fn.has('nvim-0.8') == 1 then
if db.hide_winbar then
vim.opt.winbar = ''
end
end
end,
})
if db.session_auto_save_on_exit then
local session_auto_save = api.nvim_create_augroup('session_auto_save', { clear = true })
api.nvim_create_autocmd('VimLeavePre', {
group = session_auto_save,
callback = function()
if db_session.should_auto_save() then
api.nvim_exec_autocmds('User', { pattern = 'DBSessionSavePre', modeline = false })
db_session.session_save()
api.nvim_exec_autocmds('User', { pattern = 'DBSessionSaveAfter', modeline = false })
end
end,
})
end
api.nvim_create_user_command('Dashboard', function()
require('dashboard'):instance(false)
end, {})
api.nvim_create_user_command('DashboardNewFile', function()
require('dashboard').new_file()
end, {})
api.nvim_create_user_command('SessionSave', function()
require('dashboard.session').session_save()
end, {
nargs = '?',
complete = require('dashboard.session').session_list,
})
api.nvim_create_user_command('SessionLoad', function(args)
require('dashboard.session').session_load(args.args)
end, {
nargs = '?',
complete = require('dashboard.session').session_list,
})
api.nvim_create_user_command('SessionDelete', function()
require('dashboard.session').session_delete()
end, {
nargs = '?',
complete = require('dashboard.session').session_list,
})