Skip to content
This repository was archived by the owner on Apr 16, 2024. It is now read-only.

Commit 539a1e4

Browse files
authored
fix(dashboard): Lua refactor
(Bug Fixes) - changes made following [`dashboard-nvim`](https://github.com/glepnir/dashboard-nvim) Vimscript -> Lua rewrite - add `local db = require("dashboard")` - rewrite (Vimscript) `vim.g.dashboard_custom_section` -> (Lua) `db.custom_center` - rewrite (Vimscript) `vim.g.dashboard_custom_footer` -> (Lua) `db.custom_footer` - rewrite (Vimscript) `vim.g.dashboard_custom_header` -> (Lua) `db.custom_header` - fix `custom_header` support for when user sets `config.doom.dashboard_custom_header` - fix/update header colors (highlight groups)
1 parent fa25e1d commit 539a1e4

File tree

1 file changed

+82
-51
lines changed

1 file changed

+82
-51
lines changed
Lines changed: 82 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,105 @@
11
return function()
22
local config = require("doom.core.config").config
3+
-- require [dashboard-nvim](https://github.com/glepnir/dashboard-nvim)
4+
local db = require("dashboard")
35

46
vim.g.dashboard_session_directory = require("doom.core.system").doom_root .. "/sessions"
57
vim.g.dashboard_default_executive = "telescope"
68

7-
vim.g.dashboard_custom_section = {
8-
a = {
9-
description = { " Load Last Session SPC s r" },
10-
command = "lua require('persistence').load({ last = true })",
9+
-- Custom Center
10+
db.custom_center = {
11+
{
12+
icon = "",
13+
desc = "Load Last Session ",
14+
shortcut = "SPC s r",
15+
action = "lua require('persistence').load({ last = true })"
1116
},
12-
b = {
13-
description = { " Recently Opened Files SPC f r" },
14-
command = "Telescope oldfiles",
17+
{
18+
icon = "",
19+
desc = "Recently Opened Files ",
20+
shortcut = "SPC f r",
21+
action = "lua require('telescope.builtin').oldfiles()"
1522
},
16-
c = {
17-
description = { " Jump to Bookmark SPC s m" },
18-
command = "Telescope marks",
23+
{
24+
icon = "",
25+
desc = "Jump to Bookmark ",
26+
shortcut = "SPC s m",
27+
action = "lua require('telescope.builtin').marks()"
1928
},
20-
d = {
21-
description = { " Find File SPC f f" },
22-
command = "Telescope find_files",
29+
{
30+
icon = "",
31+
desc = "Find File ",
32+
shortcut = "SPC f f",
33+
action = "lua require('telescope.builtin').find_files()"
2334
},
24-
e = {
25-
description = { " Find Word SPC s g" },
26-
command = "Telescope live_grep",
35+
{
36+
icon = "",
37+
desc = "Find Word ",
38+
shortcut = "SPC f g",
39+
action = "lua require('telescope.builtin').live_grep()"
2740
},
28-
f = {
29-
description = { " Open Private Configuration SPC d c" },
30-
command = 'lua require("doom.core.functions").edit_config()',
41+
{
42+
icon = "",
43+
desc = "Open Private Configuration ",
44+
shortcut = "SPC d c",
45+
action = "lua require('doom.core.functions').edit_config()"
3146
},
32-
g = {
33-
description = { " Open Documentation SPC d d" },
34-
command = 'lua require("doom.core.functions").open_docs()',
47+
{
48+
icon = "",
49+
desc = "Open Documentation ",
50+
shortcut = "SPC d d",
51+
action = "lua require('doom.core.functions').open_docs()"
3552
},
3653
}
3754

38-
vim.g.dashboard_custom_footer = {
55+
-- Custom Footer
56+
db.custom_footer = {
57+
"", -- add 'newline' padding between `custom_center` and `custom_footer`
3958
"Doom Nvim loaded in " .. vim.fn.printf(
4059
"%.3f",
4160
vim.fn.reltimefloat(vim.fn.reltime(vim.g.start_time))
4261
) .. " seconds.",
4362
}
4463

45-
vim.g.dashboard_custom_header = vim.tbl_isempty(config.doom.dashboard_custom_header)
46-
and {
47-
" ",
48-
"================= =============== =============== ======== ========",
49-
"\\\\ . . . . . . .\\\\ //. . . . . . .\\\\ //. . . . . . .\\\\ \\\\. . .\\\\// . . //",
50-
"||. . ._____. . .|| ||. . ._____. . .|| ||. . ._____. . .|| || . . .\\/ . . .||",
51-
"|| . .|| ||. . || || . .|| ||. . || || . .|| ||. . || ||. . . . . . . ||",
52-
"||. . || || . .|| ||. . || || . .|| ||. . || || . .|| || . | . . . . .||",
53-
"|| . .|| ||. _-|| ||-_ .|| ||. . || || . .|| ||. _-|| ||-_.|\\ . . . . ||",
54-
"||. . || ||-' || || `-|| || . .|| ||. . || ||-' || || `|\\_ . .|. .||",
55-
"|| . _|| || || || || ||_ . || || . _|| || || || |\\ `-_/| . ||",
56-
"||_-' || .|/ || || \\|. || `-_|| ||_-' || .|/ || || | \\ / |-_.||",
57-
"|| ||_-' || || `-_|| || || ||_-' || || | \\ / | `||",
58-
"|| `' || || `' || || `' || || | \\ / | ||",
59-
"|| .===' `===. .==='.`===. .===' /==. | \\/ | ||",
60-
"|| .==' \\_|-_ `===. .===' _|_ `===. .===' _-|/ `== \\/ | ||",
61-
"|| .==' _-' `-_ `=' _-' `-_ `=' _-' `-_ /| \\/ | ||",
62-
"|| .==' _-' `-__\\._-' `-_./__-' `' |. /| | ||",
63-
"||.==' _-' `' | /==.||",
64-
"==' _-' N E O V I M \\/ `==",
65-
"\\ _-' `-_ /",
66-
" `'' ``' ",
67-
}
68-
or config.doom.dashboard_custom_header
64+
-- always show tabline & statusline
65+
db.hide_tabline = false
66+
db.hide_statusline = false
67+
68+
-- Custom Header (default)
69+
db.custom_header = {
70+
" ",
71+
"================= =============== =============== ======== ========",
72+
"\\\\ . . . . . . .\\\\ //. . . . . . .\\\\ //. . . . . . .\\\\ \\\\. . .\\\\// . . //",
73+
"||. . ._____. . .|| ||. . ._____. . .|| ||. . ._____. . .|| || . . .\\/ . . .||",
74+
"|| . .|| ||. . || || . .|| ||. . || || . .|| ||. . || ||. . . . . . . ||",
75+
"||. . || || . .|| ||. . || || . .|| ||. . || || . .|| || . | . . . . .||",
76+
"|| . .|| ||. _-|| ||-_ .|| ||. . || || . .|| ||. _-|| ||-_.|\\ . . . . ||",
77+
"||. . || ||-' || || `-|| || . .|| ||. . || ||-' || || `|\\_ . .|. .||",
78+
"|| . _|| || || || || ||_ . || || . _|| || || || |\\ `-_/| . ||",
79+
"||_-' || .|/ || || \\|. || `-_|| ||_-' || .|/ || || | \\ / |-_.||",
80+
"|| ||_-' || || `-_|| || || ||_-' || || | \\ / | `||",
81+
"|| `' || || `' || || `' || || | \\ / | ||",
82+
"|| .===' `===. .==='.`===. .===' /==. | \\/ | ||",
83+
"|| .==' \\_|-_ `===. .===' _|_ `===. .===' _-|/ `== \\/ | ||",
84+
"|| .==' _-' `-_ `=' _-' `-_ `=' _-' `-_ /| \\/ | ||",
85+
"|| .==' _-' `-__\\._-' `-_./__-' `' |. /| | ||",
86+
"||.==' _-' `' | /==.||",
87+
"==' _-' N E O V I M \\/ `==",
88+
"\\ _-' `-_ /",
89+
" `'' ``' ",
90+
}
91+
92+
-- overwrite the default `custom_header` if the user sets `config.doom.dashboard_custom_header`
93+
local next = next
94+
if next(config.doom.dashboard_custom_header) ~= nil then
95+
-- user has set `config.doom.dashboard_custom_header`
96+
db.custom_header = config.doom.dashboard_custom_header
97+
end
98+
6999
-- Header color
70-
vim.cmd("hi! dashboardHeader guifg=" .. config.doom.dashboard_custom_colors.header_color)
71-
vim.cmd("hi! dashboardCenter guifg=" .. config.doom.dashboard_custom_colors.center_color)
72-
vim.cmd("hi! dashboardShortcut guifg=" .. config.doom.dashboard_custom_colors.shortcut_color)
73-
vim.cmd("hi! dashboardFooter guifg=" .. config.doom.dashboard_custom_colors.footer_color)
100+
vim.cmd("hi! DashboardHeader guifg=" .. config.doom.dashboard_custom_colors.header_color)
101+
vim.cmd("hi! DashboardCenter guifg=" .. config.doom.dashboard_custom_colors.center_color)
102+
vim.cmd("hi! DashboardCenterIcon guifg=" .. config.doom.dashboard_custom_colors.center_color)
103+
vim.cmd("hi! DashboardShortCut guifg=" .. config.doom.dashboard_custom_colors.shortcut_color)
104+
vim.cmd("hi! DashboardFooter guifg=" .. config.doom.dashboard_custom_colors.footer_color)
74105
end

0 commit comments

Comments
 (0)