mirror of
https://github.com/LunarVim/LunarVim.git
synced 2024-09-20 10:35:08 +02:00
feat(alpha): allow configuring highlight groups (#3532)
* fix(alpha): make highlights overridable Co-authored-by: CPea <42694704+cpea2506@users.noreply.github.com> * feat: make opts overridable * refactor: add default autostart to opts * feat: default_button_opts * Apply suggestions from code review Co-authored-by: kylo252 <59826753+kylo252@users.noreply.github.com> Co-authored-by: CPea <42694704+cpea2506@users.noreply.github.com> Co-authored-by: kylo252 <59826753+kylo252@users.noreply.github.com>
This commit is contained in:
parent
84ce0803e1
commit
f5454fb860
2 changed files with 36 additions and 25 deletions
|
@ -4,8 +4,16 @@ function M.config()
|
|||
local lvim_dashboard = require "lvim.core.alpha.dashboard"
|
||||
local lvim_startify = require "lvim.core.alpha.startify"
|
||||
lvim.builtin.alpha = {
|
||||
dashboard = { config = {}, section = lvim_dashboard.get_sections() },
|
||||
startify = { config = {}, section = lvim_startify.get_sections() },
|
||||
dashboard = {
|
||||
config = {},
|
||||
section = lvim_dashboard.get_sections(),
|
||||
opts = { autostart = true },
|
||||
},
|
||||
startify = {
|
||||
config = {},
|
||||
section = lvim_startify.get_sections(),
|
||||
opts = { autostart = true },
|
||||
},
|
||||
active = true,
|
||||
mode = "dashboard",
|
||||
}
|
||||
|
@ -23,6 +31,10 @@ local function resolve_buttons(theme_name, entries)
|
|||
local button_element = selected_theme.button(entry[1], entry[2], entry[3])
|
||||
-- this became necessary after recent changes in alpha.nvim (06ade3a20ca9e79a7038b98d05a23d7b6c016174)
|
||||
button_element.on_press = on_press
|
||||
|
||||
button_element.opts =
|
||||
vim.tbl_extend("force", button_element.opts, entry[4] or lvim.builtin.alpha[theme_name].section.buttons.opts)
|
||||
|
||||
table.insert(val, button_element)
|
||||
end
|
||||
return val
|
||||
|
@ -41,8 +53,13 @@ local function resolve_config(theme_name)
|
|||
resolved_section[name][k] = v
|
||||
end
|
||||
end
|
||||
|
||||
resolved_section[name].opts = el.opts or {}
|
||||
end
|
||||
|
||||
local opts = lvim.builtin.alpha[theme_name].opts or {}
|
||||
selected_theme.config.opts = vim.tbl_extend("force", selected_theme.config.opts, opts)
|
||||
|
||||
return selected_theme.config
|
||||
end
|
||||
|
||||
|
|
|
@ -114,31 +114,25 @@ function M.get_sections()
|
|||
hl = "Number",
|
||||
},
|
||||
}
|
||||
local buttons = {}
|
||||
|
||||
local status_ok, dashboard = pcall(require, "alpha.themes.dashboard")
|
||||
if status_ok then
|
||||
local function button(sc, txt, keybind, keybind_opts)
|
||||
local b = dashboard.button(sc, txt, keybind, keybind_opts)
|
||||
b.opts.hl_shortcut = "Include"
|
||||
return b
|
||||
end
|
||||
buttons = {
|
||||
val = {
|
||||
button("f", lvim.icons.ui.FindFile .. " Find File", "<CMD>Telescope find_files<CR>"),
|
||||
button("n", lvim.icons.ui.NewFile .. " New File", "<CMD>ene!<CR>"),
|
||||
button("p", lvim.icons.ui.Project .. " Projects ", "<CMD>Telescope projects<CR>"),
|
||||
button("r", lvim.icons.ui.History .. " Recent files", ":Telescope oldfiles <CR>"),
|
||||
button("t", lvim.icons.ui.FindText .. " Find Text", "<CMD>Telescope live_grep<CR>"),
|
||||
button(
|
||||
"c",
|
||||
lvim.icons.ui.Gear .. " Configuration",
|
||||
"<CMD>edit " .. require("lvim.config"):get_user_config_path() .. " <CR>"
|
||||
),
|
||||
local buttons = {
|
||||
opts = {
|
||||
hl_shortcut = "Include",
|
||||
spacing = 1,
|
||||
},
|
||||
entries = {
|
||||
{ "f", lvim.icons.ui.FindFile .. " Find File", "<CMD>Telescope find_files<CR>" },
|
||||
{ "n", lvim.icons.ui.NewFile .. " New File", "<CMD>ene!<CR>" },
|
||||
{ "p", lvim.icons.ui.Project .. " Projects ", "<CMD>Telescope projects<CR>" },
|
||||
{ "r", lvim.icons.ui.History .. " Recent files", ":Telescope oldfiles <CR>" },
|
||||
{ "t", lvim.icons.ui.FindText .. " Find Text", "<CMD>Telescope live_grep<CR>" },
|
||||
{
|
||||
"c",
|
||||
lvim.icons.ui.Gear .. " Configuration",
|
||||
"<CMD>edit " .. require("lvim.config"):get_user_config_path() .. " <CR>",
|
||||
},
|
||||
}
|
||||
end
|
||||
|
||||
},
|
||||
}
|
||||
return {
|
||||
header = header,
|
||||
buttons = buttons,
|
||||
|
|
Loading…
Reference in a new issue