feat: add alpha.nvim integration (#1906)

This commit is contained in:
kylo252 2022-03-19 20:02:45 +01:00 committed by GitHub
parent 7192b28a24
commit c946ddda81
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 280 additions and 188 deletions

View file

@ -143,6 +143,7 @@ lvim.plugins = {
- `lvim.lang.FOO` is no longer supported. Refer to <https://www.lunarvim.org/languages> for up-to-date instructions. - `lvim.lang.FOO` is no longer supported. Refer to <https://www.lunarvim.org/languages> for up-to-date instructions.
- `lvim.lsp.popup_border` has been deprecated in favor of `lvim.lsp.float.border` and `lvim.lsp.diagnostics.float.border`. - `lvim.lsp.popup_border` has been deprecated in favor of `lvim.lsp.float.border` and `lvim.lsp.diagnostics.float.border`.
- `lvim.builtin.dashboard` has been replaced with `lvim.builtin.alpha`, see <https://github.com/LunarVim/LunarVim/pull/1906>
## Resources ## Resources

View file

@ -40,20 +40,33 @@ function M:init()
local lvim_lsp_config = require "lvim.lsp.config" local lvim_lsp_config = require "lvim.lsp.config"
lvim.lsp = apply_defaults(lvim.lsp, vim.deepcopy(lvim_lsp_config)) lvim.lsp = apply_defaults(lvim.lsp, vim.deepcopy(lvim_lsp_config))
---@deprecated replaced with lvim.builtin.alpha
lvim.builtin.dashboard = {
active = false,
on_config_done = nil,
search_handler = "",
disable_at_vim_enter = 0,
session_directory = "",
custom_header = {},
custom_section = {},
footer = {},
}
require("lvim.lsp.manager").init_defaults() require("lvim.lsp.manager").init_defaults()
end end
local function handle_deprecated_settings() local function handle_deprecated_settings()
local function deprecation_notice(setting) local function deprecation_notice(setting, msg)
local in_headless = #vim.api.nvim_list_uis() == 0 local in_headless = #vim.api.nvim_list_uis() == 0
if in_headless then if in_headless then
return return
end end
local msg = string.format( msg = msg
"Deprecation notice: [%s] setting is no longer supported. See https://github.com/LunarVim/LunarVim#breaking-changes", or string.format(
setting "Deprecation notice: [%s] setting is no longer supported. See https://github.com/LunarVim/LunarVim#breaking-changes",
) setting
)
vim.schedule(function() vim.schedule(function()
Log:warn(msg) Log:warn(msg)
end) end)
@ -71,6 +84,14 @@ local function handle_deprecated_settings()
if vim.tbl_contains(vim.tbl_keys(lvim.lsp), "popup_border") then if vim.tbl_contains(vim.tbl_keys(lvim.lsp), "popup_border") then
deprecation_notice "lvim.lsp.popup_border" deprecation_notice "lvim.lsp.popup_border"
end end
-- dashboard.nvim
if lvim.builtin.dashboard.active then
deprecation_notice(
"dashboard",
"Deprecation notice: `lvim.builtin.dashboard` has been replaced with `lvim.builtin.alpha`. See LunarVim#1906"
)
end
end end
--- Override the configuration with a user provided one --- Override the configuration with a user provided one

62
lua/lvim/core/alpha.lua Normal file
View file

@ -0,0 +1,62 @@
local M = {}
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() },
active = true,
mode = "dashboard",
}
end
local function resolve_buttons(theme_name, entries)
local selected_theme = require("alpha.themes." .. theme_name)
local val = {}
for _, entry in pairs(entries) do
local on_press = function()
local sc_ = entry[1]:gsub("%s", ""):gsub("SPC", "<leader>")
local key = vim.api.nvim_replace_termcodes(sc_, true, false, true)
vim.api.nvim_feedkeys(key, "normal", false)
end
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
table.insert(val, button_element)
end
return val
end
local function resolve_config(theme_name)
local selected_theme = require("alpha.themes." .. theme_name)
local resolved_section = selected_theme.section
local section = lvim.builtin.alpha[theme_name].section
for name, el in pairs(section) do
for k, v in pairs(el) do
if name:match "buttons" and k == "entries" then
resolved_section[name].val = resolve_buttons(theme_name, v)
elseif v then
resolved_section[name][k] = v
end
end
end
return selected_theme.config
end
function M.setup()
local alpha = require "alpha"
local mode = lvim.builtin.alpha.mode
local config = lvim.builtin.alpha[mode].config
-- this makes it easier to use a completely custom configuration
if vim.tbl_isempty(config) then
config = resolve_config(mode)
end
alpha.setup(config)
end
return M

View file

@ -0,0 +1,83 @@
local M = {}
function M.get_sections()
local header = {
type = "text",
val = {
"",
"",
"⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣀⣤⣤⣶⣶⣶⣶⣶⣶⣶⣦⣤⣄⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀",
"⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⣴⣾⣿⠿⠛⠛⠉⠉⠉⠉⠉⠉⠉⠙⠛⠻⢿⣿⣶⣤⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀",
"⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣴⣿⠿⠛⠉⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠻⢿⣷⣤⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀",
"⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣴⣿⠟⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⢿⣿⣦⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀",
"⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡠⠒⠈⠉⠉⠉⠉⠉⣹⣿⠟⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⢿⣷⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀",
"⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠸⡀⠀⠀⠀⠀⠀⠀⣰⣿⠏⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⢿⣿⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀",
"⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠑⢄⠀⠀⠀⠀⢰⣿⠏⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⢿⣿⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀",
"⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠑⢄⡀⠀⣿⡟⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⣿⣧⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀",
"⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⢺⣿⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀",
"⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⠉⠑⠢⢄⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀",
"⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⣿⡇⠀⠀⠀⠈⠑⠢⠄⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⠢⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀",
"⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢿⣇⠀⠀⠀⠀⠀⠀⠀⠀⠉⠐⠢⠄⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢰⣿⡟⠀⠈⠑⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀",
"⠀⠀⠀⠀⠀⠀⢀⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⣿⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠁⠒⠠⠤⣀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣾⣿⠁⠀⠀⢀⣼⣦⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀",
"⠀⠀⠀⠀⠀⠀⢸⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠹⣷⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠁⠒⠂⠤⠤⠀⣀⡀⠀⠀⠀⣼⣿⠇⠀⠀⢀⣸⣿⡿⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀",
"⠀⠀⠀⠀⠀⠀⣿⡟⠀⠀⠀⠀⠀⠀⣤⡄⠀⠀⠀⣠⣤⠀⠀⢠⣭⣀⣤⣤⣤⡀⠀⠀⠀⢀⣤⣤⣤⣤⡀⠀⠀⠀⢠⣤⢀⣤⣤⣄⠀⠀⣿⣿⠀⠉⣹⣿⠏⠉⠉⢱⣶⣶⣶⡦⠀⠀⠀⢠⣶⣦⣴⣦⣠⣴⣦⡀⠀⠀⠀⠀",
"⠀⠀⠀⠀⠀⢠⣿⡇⠀⠀⠀⠀⠀⢠⣿⠇⠀⠀⠀⣿⡇⠀⠀⣿⡿⠉⠀⠈⣿⣧⠀⠀⠰⠿⠋⠀⠀⢹⣿⠀⠀⠀⣿⡿⠋⠀⠹⠿⠀⠀⢻⣿⡇⢠⣿⡟⠀⠀⠀⠈⠉⢹⣿⡇⠀⠀⠀⢸⣿⡏⢹⣿⡏⢹⣿⡇⠀⠀⠀⠀",
"⠀⠀⠀⠀⠀⢸⣿⠀⠀⠀⠀⠀⠀⢸⣿⠀⠀⠀⢰⣿⠃⠀⢠⣿⡇⠀⠀⠀⣿⡇⠀⠀⣠⣴⡶⠶⠶⣿⣿⠀⠀⢠⣿⡇⠀⠀⠀⠀⠀⠀⢸⣿⣇⣿⡿⠀⠀⠀⠀⠀⠀⣿⣿⠁⠀⠀⠀⣿⣿⠀⣾⣿⠀⣾⣿⠁⠀⠀⠀⠀",
"⠀⠀⠀⠀⠀⣿⣟⠀⠀⠀⠀⠀⠀⢻⣿⡀⠀⢀⣼⣿⠀⠀⢸⣿⠀⠀⠀⢰⣿⠇⠀⢰⣿⣇⠀⠀⣠⣿⡏⠀⠀⢸⣿⠀⠀⠀⠀⠀⠀⠀⢸⣿⣿⣿⠁⠀⠀⠀⣀⣀⣠⣿⣿⣀⡀⠀⢠⣿⡟⢠⣿⡟⢀⣿⡿⠀⠀⠀⠀⠀",
"⠀⠀⠀⠀⠀⠛⠛⠛⠛⠛⠛⠁⠀⠈⠛⠿⠟⠋⠛⠃⠀⠀⠛⠛⠀⠀⠀⠘⠛⠀⠀⠀⠙⠿⠿⠛⠙⠛⠃⠀⠀⠚⠛⠀⠀⠀⠀⠀⠀⠀⠘⠿⠿⠃⠀⠀⠀⠀⠿⠿⠿⠿⠿⠿⠿⠀⠸⠿⠇⠸⠿⠇⠸⠿⠇⠀⠀⠀⠀⠀",
" ",
},
opts = {
position = "center",
hl = "Label",
},
}
local text = require "lvim.interface.text"
local git_utils = require "lvim.utils.git"
local current_branch = git_utils.get_lvim_branch()
local lvim_version
if current_branch ~= "HEAD" or "" then
lvim_version = current_branch .. "-" .. git_utils.get_lvim_current_sha()
else
lvim_version = "v" .. git_utils.get_lvim_tag()
end
local footer = {
type = "text",
val = text.align_center({ width = 0 }, {
"",
"lunarvim.org",
lvim_version,
}, 0.5),
opts = {
position = "center",
hl = "Number",
},
}
local buttons = {
entries = {
{ "SPC f", " Find File", "<CMD>Telescope find_files<CR>" },
{ "SPC n", " New File", "<CMD>ene!<CR>" },
{ "SPC P", " Recent Projects ", "<CMD>Telescope projects<CR>" },
{ "SPC s r", " Recently Used Files", "<CMD>Telescope oldfiles<CR>" },
{ "SPC s t", " Find Word", "<CMD>Telescope live_grep<CR>" },
{
"SPC L c",
" Configuration",
"<CMD>edit " .. require("lvim.config").get_user_config_path() .. " <CR>",
},
},
}
return {
header = header,
buttons = buttons,
footer = footer,
}
end
return M

View file

@ -0,0 +1,48 @@
local M = {}
function M.get_sections()
local header = {
type = "text",
val = {
[[ __ _ ___ ]],
[[ / / __ ______ ____ _____| | / (_)___ ___ ]],
[[ / / / / / / __ \/ __ `/ ___/ | / / / __ `__ \]],
[[ / /___/ /_/ / / / / /_/ / / | |/ / / / / / / /]],
[[/_____/\__,_/_/ /_/\__,_/_/ |___/_/_/ /_/ /_/ ]],
},
opts = {
hl = "Label",
shrink_margin = false,
-- wrap = "overflow";
},
}
local top_buttons = {
entries = {
{ "e", " New File", "<CMD>ene!<CR>" },
},
val = {},
}
local bottom_buttons = {
entries = {
{ "q", "Quit", "<CMD>quit<CR>" },
},
val = {},
}
local footer = {
type = "group",
val = {},
}
return {
header = header,
top_buttons = top_buttons,
bottom_buttons = bottom_buttons,
-- this is probably broken
footer = footer,
}
end
return M

View file

@ -53,6 +53,19 @@ function M.load_augroups()
_general_lsp = { _general_lsp = {
{ "FileType", "lspinfo,lsp-installer,null-ls-info", "nnoremap <silent> <buffer> q :close<CR>" }, { "FileType", "lspinfo,lsp-installer,null-ls-info", "nnoremap <silent> <buffer> q :close<CR>" },
}, },
_alpha = {
{
"FileType",
"alpha",
"set showtabline=0 | autocmd BufLeave <buffer> set showtabline=" .. vim.opt.showtabline._value,
},
-- https://github.com/goolord/alpha-nvim/issues/42
{
"FileType",
"alpha",
"set laststatus=0 | autocmd BufUnload <buffer> set laststatus=" .. vim.opt.laststatus._value,
},
},
custom_groups = {}, custom_groups = {},
} }
end end

View file

@ -4,7 +4,6 @@ local builtins = {
"lvim.core.which-key", "lvim.core.which-key",
"lvim.core.gitsigns", "lvim.core.gitsigns",
"lvim.core.cmp", "lvim.core.cmp",
"lvim.core.dashboard",
"lvim.core.dap", "lvim.core.dap",
"lvim.core.terminal", "lvim.core.terminal",
"lvim.core.telescope", "lvim.core.telescope",
@ -16,6 +15,7 @@ local builtins = {
"lvim.core.comment", "lvim.core.comment",
"lvim.core.notify", "lvim.core.notify",
"lvim.core.lualine", "lvim.core.lualine",
"lvim.core.alpha",
} }
function M.config(config) function M.config(config)

View file

@ -1,115 +0,0 @@
local M = {}
local utils = require "lvim.utils"
M.config = function(config)
lvim.builtin.dashboard = {
active = false,
on_config_done = nil,
search_handler = "telescope",
disable_at_vim_enter = 0,
session_directory = utils.join_paths(get_cache_dir(), "sessions"),
custom_header = {
"⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣀⣀⣀⣀⣀⣀⣀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀",
"⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⣤⣶⣾⠿⠿⠟⠛⠛⠛⠛⠿⠿⣿⣷⣤⣄⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀",
" ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣠⣾⡿⠋⠉⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠙⠿⣷⣤⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀",
"⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣤⡿⠛⠉⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠛⢿⣦⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀",
"⠀⠀⠀⠀⠀⠀⠀⠀⠀⡠⠒⠂⠉⠉⠉⠉⢩⣿⡿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠹⣷⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀",
"⠀⠀⠀⠀⠀⠀⠀⠀⠸⡀⠀⠀⠀⠀⠀⢰⣿⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⣿⣧⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀",
"⠀⠀⠀⠀⠀⠀⠀⠀⠀⠑⠠⡀⠀⠀⢀⣾⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⣿⡆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀",
"⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠢⢀⣸⡟⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢹⣇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀",
"⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⡧⢄⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀",
"⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⡇⠀⠈⠁⠒⠤⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀",
"⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣇⠀⠀⠀⠀⠀⠀⠉⠢⠤⠀⢀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣸⡟⠈⠑⠄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀",
"⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢿⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠑⠒⠤⣀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠⣿⡇⠀⠀⢀⣣⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀",
"⠀⣿⡟⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠸⣷⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠀⠀⠒⠢⠤⠄⣀⣀⠀⠀⠀⢠⣿⡟⠀⠀⠀⣺⣿⡿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀",
"⠀⣿⠇⠀⠀⠀⠀⠀⣤⡄⠀⠀⢠⣤⡄⠀⢨⣭⣠⣤⣤⣤⡀⠀⠀⢀⣤⣤⣤⣤⡄⠀⠀⠀⣤⣄⣤⣤⣤⠀⠀⣿⣯⠉⠉⣿⡟⠀⠈⢩⣭⣤⣤⠀⠀⠀⠀⣠⣤⣤⣤⣄⣤⣤",
"⢠⣿⠀⠀⠀⠀⠀⠀⣿⠃⠀⠀⣸⣿⠁⠀⣿⣿⠉⠀⠈⣿⡇⠀⠀⠛⠋⠀⠀⢹⣿⠀⠀⠀⣿⠏⠀⠸⠿⠃⠀⣿⣿⠀⣰⡟⠀⠀⠀⠀⠀⢸⣿⠀⠀⠀⠀⣿⡟⢸⣿⡇⢀⣿",
"⣸⡇⠀⠀⠀⠀⠀⢸⣿⠀⠀⠀⣿⡟⠀⢠⣿⡇⠀⠀⢰⣿⡇⠀⣰⣾⠟⠛⠛⣻⡇⠀⠀⢸⡿⠀⠀⠀⠀⠀⠀⢻⣿⢰⣿⠀⠀⠀⠀⠀⠀⣾⡇⠀⠀⠀⢸⣿⠇⢸⣿⠀⢸⡏",
"⣿⣧⣤⣤⣤⡄⠀⠘⣿⣤⣤⡤⣿⠇⠀⢸⣿⠁⠀⠀⣼⣿⠀⠀⢿⣿⣤⣤⠔⣿⠃⠀⠀⣾⡇⠀⠀⠀⠀⠀⠀⢸⣿⣿⠋⠀⠀⠀⢠⣤⣤⣿⣥⣤⡄⠀⣼⣿⠀⣸⡏⠀⣿⠃",
"⠉⠉⠉⠉⠉⠁⠀⠀⠈⠉⠉⠀⠉⠀⠀⠈⠉⠀⠀⠀⠉⠉⠀⠀⠀⠉⠉⠁⠈⠉⠀⠀⠀⠉⠀⠀⠀⠀⠀⠀⠀⠈⠉⠉⠀⠀⠀⠀⠈⠉⠉⠉⠉⠉⠁⠀⠉⠁⠀⠉⠁⠀⠉⠀",
},
custom_section = {
a = {
description = { " Find File " },
command = "Telescope find_files",
},
b = {
description = { " New File " },
command = ":ene!",
},
c = {
description = { " Recent Projects " },
command = "Telescope projects",
},
d = {
description = { " Recently Used Files" },
command = "Telescope oldfiles",
},
e = {
description = { " Find Word " },
command = "Telescope live_grep",
},
f = {
description = { " Configuration " },
command = ":e " .. config.user_config_file,
},
},
footer = { "lunarvim.org" },
}
lvim.builtin.which_key.mappings[";"] = { "<cmd>Dashboard<CR>", "Dashboard" }
end
M.setup = function()
vim.g.dashboard_disable_at_vimenter = lvim.builtin.dashboard.disable_at_vim_enter
vim.g.dashboard_custom_header = lvim.builtin.dashboard.custom_header
vim.g.dashboard_default_executive = lvim.builtin.dashboard.search_handler
vim.g.dashboard_custom_section = lvim.builtin.dashboard.custom_section
vim.g.dashboard_session_directory = lvim.builtin.dashboard.session_directory
local lvim_site = "lunarvim.org"
local lvim_version = require("lvim.utils.git"):get_lvim_version "short"
local num_plugins_loaded = #vim.fn.globpath(get_runtime_dir() .. "/site/pack/packer/start", "*", 0, 1)
local footer = {
"LunarVim loaded " .. num_plugins_loaded .. " plugins ",
"",
lvim_site,
}
if lvim_version then
table.insert(footer, 2, "")
table.insert(footer, 2, lvim_version)
end
local text = require "lvim.interface.text"
vim.g.dashboard_custom_footer = text.align_center({ width = 0 }, footer, 0.49) -- Use 0.49 as  counts for 2 characters
require("lvim.core.autocmds").define_augroups {
_dashboard = {
-- seems to be nobuflisted that makes my stuff disappear will do more testing
{
"FileType",
"dashboard",
"setlocal nocursorline noswapfile synmaxcol& signcolumn=no norelativenumber nocursorcolumn nospell nolist nonumber bufhidden=wipe colorcolumn= foldcolumn=0 matchpairs= ",
},
{
"FileType",
"dashboard",
"set showtabline=0 | autocmd BufLeave <buffer> set showtabline=" .. vim.opt.showtabline._value,
},
{ "FileType", "dashboard", "nnoremap <silent> <buffer> q :q<CR>" },
},
}
if lvim.builtin.dashboard.on_config_done then
lvim.builtin.dashboard.on_config_done()
end
end
return M

View file

@ -34,8 +34,14 @@ M.config = function()
end end
M.setup = function() M.setup = function()
-- avoid running in headless mode since it's harder to detect failures
if #vim.api.nvim_list_uis() == 0 then
local Log = require "lvim.core.log"
Log:debug "headless mode detected, skipping running setup for lualine"
return
end
require("lvim.core.lualine.styles").update() require("lvim.core.lualine.styles").update()
require("lvim.core.lualine.utils").validate_theme()
local lualine = require "lualine" local lualine = require "lualine"
lualine.setup(lvim.builtin.lualine) lualine.setup(lvim.builtin.lualine)

View file

@ -10,6 +10,7 @@ local styles = {
styles.none = { styles.none = {
style = "none", style = "none",
options = { options = {
theme = "auto",
icons_enabled = true, icons_enabled = true,
component_separators = { left = "", right = "" }, component_separators = { left = "", right = "" },
section_separators = { left = "", right = "" }, section_separators = { left = "", right = "" },
@ -38,6 +39,7 @@ styles.none = {
styles.default = { styles.default = {
style = "default", style = "default",
options = { options = {
theme = "auto",
icons_enabled = true, icons_enabled = true,
component_separators = { left = "", right = "" }, component_separators = { left = "", right = "" },
section_separators = { left = "", right = "" }, section_separators = { left = "", right = "" },
@ -66,10 +68,11 @@ styles.default = {
styles.lvim = { styles.lvim = {
style = "lvim", style = "lvim",
options = { options = {
theme = "auto",
icons_enabled = true, icons_enabled = true,
component_separators = { left = "", right = "" }, component_separators = { left = "", right = "" },
section_separators = { left = "", right = "" }, section_separators = { left = "", right = "" },
disabled_filetypes = { "dashboard", "NvimTree", "Outline" }, disabled_filetypes = { "alpha", "NvimTree", "Outline" },
}, },
sections = { sections = {
lualine_a = { lualine_a = {
@ -113,10 +116,10 @@ function M.get_style(style)
if not vim.tbl_contains(style_keys, style) then if not vim.tbl_contains(style_keys, style) then
local Log = require "lvim.core.log" local Log = require "lvim.core.log"
Log:error( Log:error(
"Invalid lualine style", "Invalid lualine style"
string.format('"%s"', style), .. string.format('"%s"', style)
"options are: ", .. "options are: "
string.format('"%s"', table.concat(style_keys, '", "')) .. string.format('"%s"', table.concat(style_keys, '", "'))
) )
Log:debug '"lvim" style is applied.' Log:debug '"lvim" style is applied.'
style = "lvim" style = "lvim"

View file

@ -1,18 +1,5 @@
local M = {} local M = {}
function M.validate_theme()
local theme = lvim.builtin.lualine.options.theme or "auto"
if type(theme) == "table" then
return
end
local lualine_loader = require "lualine.utils.loader"
local ok = pcall(lualine_loader.load_theme, theme)
if not ok then
lvim.builtin.lualine.options.theme = "auto"
end
end
function M.env_cleanup(venv) function M.env_cleanup(venv)
if string.find(venv, "/") then if string.find(venv, "/") then
local final_venv = venv local final_venv = venv

View file

@ -64,6 +64,7 @@ M.config = function()
["/"] = { "<ESC><CMD>lua require('Comment.api').toggle_linewise_op(vim.fn.visualmode())<CR>", "Comment" }, ["/"] = { "<ESC><CMD>lua require('Comment.api').toggle_linewise_op(vim.fn.visualmode())<CR>", "Comment" },
}, },
mappings = { mappings = {
[";"] = { "<cmd>Alpha<CR>", "Dashboard" },
["w"] = { "<cmd>w!<CR>", "Save" }, ["w"] = { "<cmd>w!<CR>", "Save" },
["q"] = { "<cmd>q!<CR>", "Quit" }, ["q"] = { "<cmd>q!<CR>", "Quit" },
["/"] = { "<cmd>lua require('Comment.api').toggle_current_linewise()<CR>", "Comment" }, ["/"] = { "<cmd>lua require('Comment.api').toggle_current_linewise()<CR>", "Comment" },

View file

@ -1,12 +1,12 @@
local commit = { local commit = {
bufferline = "f63be9a3a3429a726af14c9085d547281bdf38cc", alpha_nvim = "14be0ac200f44009672046123c6fcb30724018a5",
bufferline = "5e101b1b4e1ea5b868b8865a5f749b0b5b8f3ccd",
cmp_buffer = "d66c4c2d376e5be99db68d2362cd94d250987525", cmp_buffer = "d66c4c2d376e5be99db68d2362cd94d250987525",
cmp_luasnip = "d6f837f4e8fe48eeae288e638691b91b97d1737f", cmp_luasnip = "d6f837f4e8fe48eeae288e638691b91b97d1737f",
cmp_nvim_lsp = "ebdfc204afb87f15ce3d3d3f5df0b8181443b5ba", cmp_nvim_lsp = "ebdfc204afb87f15ce3d3d3f5df0b8181443b5ba",
cmp_path = "466b6b8270f7ba89abd59f402c73f63c7331ff6e", cmp_path = "466b6b8270f7ba89abd59f402c73f63c7331ff6e",
comment = "a841f73523440c4f32d39f0290cf1e691311db2a", comment = "a841f73523440c4f32d39f0290cf1e691311db2a",
dapinstall = "24923c3819a450a772bb8f675926d530e829665f", dapinstall = "24923c3819a450a772bb8f675926d530e829665f",
dashboard_nvim = "d82ddae95fd4dc4c3b7bbe87f09b1840fbf20ecb",
fixcursorhold = "1bfb32e7ba1344925ad815cb0d7f901dbc0ff7c1", fixcursorhold = "1bfb32e7ba1344925ad815cb0d7f901dbc0ff7c1",
friendly_snippets = "ad07b2844021b20797adda5b483265802559a693", friendly_snippets = "ad07b2844021b20797adda5b483265802559a693",
gitsigns = "2df360de757c39c04076cb04bcbbd361dec3c8c2", gitsigns = "2df360de757c39c04076cb04bcbbd361dec3c8c2",
@ -25,6 +25,7 @@ local commit = {
nvim_treesitter = "fd92e70c69330dd8f2f6753d3d987c34e7dacd24", nvim_treesitter = "fd92e70c69330dd8f2f6753d3d987c34e7dacd24",
nvim_ts_context_commentstring = "097df33c9ef5bbd3828105e4bee99965b758dc3f", nvim_ts_context_commentstring = "097df33c9ef5bbd3828105e4bee99965b758dc3f",
nvim_web_devicons = "4415d1aaa56f73b9c05795af84d625c610b05d3b", nvim_web_devicons = "4415d1aaa56f73b9c05795af84d625c610b05d3b",
onedarker = "b00dd2189f264c5aeb4cf04c59439655ecd573ec",
packer = "c576ab3f1488ee86d60fd340d01ade08dcabd256", packer = "c576ab3f1488ee86d60fd340d01ade08dcabd256",
plenary = "14dfb4071022b22e08384ee125a5607464b6d397", plenary = "14dfb4071022b22e08384ee125a5607464b6d397",
popup = "b7404d35d5d3548a82149238289fa71f7f6de4ac", popup = "b7404d35d5d3548a82149238289fa71f7f6de4ac",
@ -57,6 +58,7 @@ return {
require("onedarker").setup() require("onedarker").setup()
lvim.builtin.lualine.options.theme = "onedarker" lvim.builtin.lualine.options.theme = "onedarker"
end, end,
commit = commit.onedarker,
disable = lvim.colorscheme ~= "onedarker", disable = lvim.colorscheme ~= "onedarker",
}, },
{ {
@ -262,14 +264,14 @@ return {
disable = not lvim.builtin.dap.active, disable = not lvim.builtin.dap.active,
}, },
-- Dashboard -- alpha
{ {
"ChristianChiarulli/dashboard-nvim", "goolord/alpha-nvim",
event = "BufWinEnter",
config = function() config = function()
require("lvim.core.dashboard").setup() require("lvim.core.alpha").setup()
end, end,
disable = not lvim.builtin.dashboard.active, commit = commit.alpha_nvim,
disable = not lvim.builtin.alpha.active,
}, },
-- Terminal -- Terminal

View file

@ -1,11 +1,12 @@
local M = {} local M = {}
local Log = require "lvim.core.log" local Log = require "lvim.core.log"
local if_nil = vim.F.if_nil
local function git_cmd(opts) local function git_cmd(opts)
local plenary_loaded, Job = pcall(require, "plenary.job") local plenary_loaded, Job = pcall(require, "plenary.job")
if not plenary_loaded then if not plenary_loaded then
vim.cmd "packadd plenary.nvim" return 1, { "" }
end end
opts = opts or {} opts = opts or {}
@ -89,51 +90,27 @@ end
---Get the current Lunarvim development branch ---Get the current Lunarvim development branch
---@return string|nil ---@return string|nil
function M.get_lvim_branch() function M.get_lvim_branch()
local ret, branch = git_cmd { args = { "rev-parse", "--abbrev-ref", "HEAD" } } local _, results = git_cmd { args = { "rev-parse", "--abbrev-ref", "HEAD" } }
if ret ~= 0 or (not branch or branch[1] == "") then local branch = if_nil(results[1], "")
Log:error "Unable to retrieve the name of the current branch. Check the log for further information" return branch
return
end
return branch[1]
end end
---Get currently checked-out tag of Lunarvim ---Get currently checked-out tag of Lunarvim
---@param type string can be "short" ---@return string
---@return string|nil function M.get_lvim_tag()
function M.get_lvim_tag(type) local args = { "describe", "--tags", "--abbrev=0" }
type = type or ""
local ret, results = git_cmd { args = { "describe", "--tags" } }
local lvim_full_ver = results[1] or ""
if ret ~= 0 or string.match(lvim_full_ver, "%d") == nil then local _, results = git_cmd { args = args }
return nil local tag = if_nil(results[1], "")
end return tag
if type == "short" then
return vim.fn.split(lvim_full_ver, "-")[1]
else
return string.sub(lvim_full_ver, 1, #lvim_full_ver - 1)
end
end end
---Get the commit hash of currently checked-out commit of Lunarvim ---Get the commit hash of currently checked-out commit of Lunarvim
---@param type string can be "short"
---@return string|nil ---@return string|nil
function M.get_lvim_version(type) function M.get_lvim_current_sha()
type = type or "" local _, log_results = git_cmd { args = { "log", "--pretty=format:%h", "-1" } }
local branch = M.get_lvim_branch() local abbrev_version = if_nil(log_results[1], "")
if branch == "master" then return abbrev_version
return M.get_lvim_tag(type)
end
local ret, log_results = git_cmd { args = { "log", "--pretty=format:%h", "-1" } }
local abbrev_version = log_results[1] or ""
if ret ~= 0 or string.match(abbrev_version, "%d") == nil then
Log:error "Unable to retrieve current version. Check the log for further information"
return nil
end
if type == "short" then
return abbrev_version
end
return branch .. "-" .. abbrev_version
end end
function M.generate_plugins_sha(output) function M.generate_plugins_sha(output)

View file

@ -12,8 +12,10 @@ function M.run_pre_reload()
end end
function M.run_on_packer_complete() function M.run_on_packer_complete()
-- manually trigger event to fix colors if not in_headless then
vim.cmd [[ doautocmd ColorScheme ]] -- manually trigger event to fix colors
vim.cmd [[ doautocmd ColorScheme ]]
end
Log:info "Reloaded configuration" Log:info "Reloaded configuration"
end end

View file

@ -54,7 +54,8 @@ lvim.keys.normal_mode["<C-s>"] = ":w<cr>"
-- TODO: User Config for predefined plugins -- TODO: User Config for predefined plugins
-- After changing plugin config exit and reopen LunarVim, Run :PackerInstall :PackerCompile -- After changing plugin config exit and reopen LunarVim, Run :PackerInstall :PackerCompile
lvim.builtin.dashboard.active = true lvim.builtin.alpha.active = true
lvim.builtin.alpha.mode = "dashboard"
lvim.builtin.notify.active = true lvim.builtin.notify.active = true
lvim.builtin.terminal.active = true lvim.builtin.terminal.active = true
lvim.builtin.nvimtree.setup.view.side = "left" lvim.builtin.nvimtree.setup.view.side = "left"