diff options
author | kylo252 <[email protected]> | 2022-03-24 15:48:33 +0100 |
---|---|---|
committer | kylo252 <[email protected]> | 2022-03-24 15:48:33 +0100 |
commit | f41edc6dfb0d2a4c9875da08bbbdab121e52048f (patch) | |
tree | c6541278c6314e58d991bc95e547e903ac58340a /lua/lvim | |
parent | 5ee460fdc751a91cdf7a4f4aab2ab784ebdb36fd (diff) | |
parent | 1ea836e3601b7ed0ed0496888dc14683bfbcce75 (diff) |
Merge remote-tracking branch 'origin/rolling'1.1.3
Diffstat (limited to 'lua/lvim')
-rw-r--r-- | lua/lvim/config/init.lua | 31 | ||||
-rw-r--r-- | lua/lvim/core/alpha.lua | 83 | ||||
-rw-r--r-- | lua/lvim/core/alpha/dashboard.lua | 83 | ||||
-rw-r--r-- | lua/lvim/core/alpha/startify.lua | 48 | ||||
-rw-r--r-- | lua/lvim/core/bufferline.lua | 2 | ||||
-rw-r--r-- | lua/lvim/core/builtins/init.lua | 2 | ||||
-rw-r--r-- | lua/lvim/core/dashboard.lua | 115 | ||||
-rw-r--r-- | lua/lvim/core/lualine/init.lua | 9 | ||||
-rw-r--r-- | lua/lvim/core/lualine/styles.lua | 16 | ||||
-rw-r--r-- | lua/lvim/core/lualine/utils.lua | 13 | ||||
-rw-r--r-- | lua/lvim/core/nvimtree.lua | 1 | ||||
-rw-r--r-- | lua/lvim/core/terminal.lua | 3 | ||||
-rw-r--r-- | lua/lvim/core/which-key.lua | 2 | ||||
-rw-r--r-- | lua/lvim/lsp/config.lua | 1 | ||||
-rw-r--r-- | lua/lvim/lsp/peek.lua | 16 | ||||
-rw-r--r-- | lua/lvim/plugin-loader.lua | 7 | ||||
-rw-r--r-- | lua/lvim/plugins.lua | 61 | ||||
-rw-r--r-- | lua/lvim/utils/git.lua | 53 | ||||
-rw-r--r-- | lua/lvim/utils/hooks.lua | 6 |
19 files changed, 332 insertions, 220 deletions
diff --git a/lua/lvim/config/init.lua b/lua/lvim/config/init.lua index de06aa89..c3fe0438 100644 --- a/lua/lvim/config/init.lua +++ b/lua/lvim/config/init.lua @@ -40,20 +40,33 @@ function M:init() local lvim_lsp_config = require "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() end 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 if in_headless then return end - local msg = string.format( - "Deprecation notice: [%s] setting is no longer supported. See https://github.com/LunarVim/LunarVim#breaking-changes", - setting - ) + msg = msg + or string.format( + "Deprecation notice: [%s] setting is no longer supported. See https://github.com/LunarVim/LunarVim#breaking-changes", + setting + ) vim.schedule(function() Log:warn(msg) end) @@ -71,6 +84,14 @@ local function handle_deprecated_settings() if vim.tbl_contains(vim.tbl_keys(lvim.lsp), "popup_border") then deprecation_notice "lvim.lsp.popup_border" 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 --- Override the configuration with a user provided one diff --git a/lua/lvim/core/alpha.lua b/lua/lvim/core/alpha.lua new file mode 100644 index 00000000..7612854b --- /dev/null +++ b/lua/lvim/core/alpha.lua @@ -0,0 +1,83 @@ +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 + +local function configure_additional_autocmds() + local aucmds = { + { + "FileType", + "alpha", + "set showtabline=0 | autocmd BufLeave <buffer> set showtabline=" .. vim.opt.showtabline._value, + }, + } + if not lvim.builtin.lualine.options.globalstatus then + aucmds[#aucmds + 1] = + -- https://github.com/goolord/alpha-nvim/issues/42 + { + "FileType", + "alpha", + "set laststatus=0 | autocmd BufUnload <buffer> set laststatus=" .. vim.opt.laststatus._value, + } + end + require("lvim.core.autocmds").define_augroups { _alpha = aucmds } +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) + configure_additional_autocmds() +end + +return M diff --git a/lua/lvim/core/alpha/dashboard.lua b/lua/lvim/core/alpha/dashboard.lua new file mode 100644 index 00000000..010d8c1a --- /dev/null +++ b/lua/lvim/core/alpha/dashboard.lua @@ -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 diff --git a/lua/lvim/core/alpha/startify.lua b/lua/lvim/core/alpha/startify.lua new file mode 100644 index 00000000..2ea541f5 --- /dev/null +++ b/lua/lvim/core/alpha/startify.lua @@ -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 diff --git a/lua/lvim/core/bufferline.lua b/lua/lvim/core/bufferline.lua index c7b5fd2d..d16c3d79 100644 --- a/lua/lvim/core/bufferline.lua +++ b/lua/lvim/core/bufferline.lua @@ -9,7 +9,7 @@ local function diagnostics_indicator(_, _, diagnostics) local symbols = { error = "", warning = "", info = "" } for name, count in pairs(diagnostics) do if symbols[name] and count > 0 then - table.insert(result, symbols[name] .. count) + table.insert(result, symbols[name] .. " " .. count) end end result = table.concat(result, " ") diff --git a/lua/lvim/core/builtins/init.lua b/lua/lvim/core/builtins/init.lua index cd47b638..e219d45e 100644 --- a/lua/lvim/core/builtins/init.lua +++ b/lua/lvim/core/builtins/init.lua @@ -4,7 +4,6 @@ local builtins = { "lvim.core.which-key", "lvim.core.gitsigns", "lvim.core.cmp", - "lvim.core.dashboard", "lvim.core.dap", "lvim.core.terminal", "lvim.core.telescope", @@ -16,6 +15,7 @@ local builtins = { "lvim.core.comment", "lvim.core.notify", "lvim.core.lualine", + "lvim.core.alpha", } function M.config(config) diff --git a/lua/lvim/core/dashboard.lua b/lua/lvim/core/dashboard.lua deleted file mode 100644 index 438b46f3..00000000 --- a/lua/lvim/core/dashboard.lua +++ /dev/null @@ -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 diff --git a/lua/lvim/core/lualine/init.lua b/lua/lvim/core/lualine/init.lua index c5d024c2..e041e8a8 100644 --- a/lua/lvim/core/lualine/init.lua +++ b/lua/lvim/core/lualine/init.lua @@ -9,6 +9,7 @@ M.config = function() section_separators = nil, theme = nil, disabled_filetypes = nil, + globalstatus = false, }, sections = { lualine_a = nil, @@ -33,8 +34,14 @@ M.config = function() end 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.utils").validate_theme() local lualine = require "lualine" lualine.setup(lvim.builtin.lualine) diff --git a/lua/lvim/core/lualine/styles.lua b/lua/lvim/core/lualine/styles.lua index 0843aead..45c6c639 100644 --- a/lua/lvim/core/lualine/styles.lua +++ b/lua/lvim/core/lualine/styles.lua @@ -10,6 +10,7 @@ local styles = { styles.none = { style = "none", options = { + theme = "auto", icons_enabled = true, component_separators = { left = "", right = "" }, section_separators = { left = "", right = "" }, @@ -38,6 +39,7 @@ styles.none = { styles.default = { style = "default", options = { + theme = "auto", icons_enabled = true, component_separators = { left = "", right = "" }, section_separators = { left = "", right = "" }, @@ -66,10 +68,11 @@ styles.default = { styles.lvim = { style = "lvim", options = { + theme = "auto", icons_enabled = true, component_separators = { left = "", right = "" }, section_separators = { left = "", right = "" }, - disabled_filetypes = { "dashboard", "NvimTree", "Outline" }, + disabled_filetypes = { "alpha", "NvimTree", "Outline" }, }, sections = { lualine_a = { @@ -113,10 +116,10 @@ function M.get_style(style) if not vim.tbl_contains(style_keys, style) then local Log = require "lvim.core.log" Log:error( - "Invalid lualine style", - string.format('"%s"', style), - "options are: ", - string.format('"%s"', table.concat(style_keys, '", "')) + "Invalid lualine style" + .. string.format('"%s"', style) + .. "options are: " + .. string.format('"%s"', table.concat(style_keys, '", "')) ) Log:debug '"lvim" style is applied.' style = "lvim" @@ -127,9 +130,6 @@ end function M.update() local style = M.get_style(lvim.builtin.lualine.style) - if lvim.builtin.lualine.options.theme == nil then - lvim.builtin.lualine.options.theme = lvim.colorscheme - end lvim.builtin.lualine = vim.tbl_deep_extend("keep", lvim.builtin.lualine, style) end diff --git a/lua/lvim/core/lualine/utils.lua b/lua/lvim/core/lualine/utils.lua index cf80a99e..3fd3c2d3 100644 --- a/lua/lvim/core/lualine/utils.lua +++ b/lua/lvim/core/lualine/utils.lua @@ -1,18 +1,5 @@ local M = {} -function M.validate_theme() - local theme = lvim.builtin.lualine.options.theme - 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) if string.find(venv, "/") then local final_venv = venv diff --git a/lua/lvim/core/nvimtree.lua b/lua/lvim/core/nvimtree.lua index 6b6997ca..bcdf963d 100644 --- a/lua/lvim/core/nvimtree.lua +++ b/lua/lvim/core/nvimtree.lua @@ -79,6 +79,7 @@ function M.config() global = false, }, open_file = { + resize_window = true, quit_on_open = false, }, window_picker = { diff --git a/lua/lvim/core/terminal.lua b/lua/lvim/core/terminal.lua index 441ab61e..69492a57 100644 --- a/lua/lvim/core/terminal.lua +++ b/lua/lvim/core/terminal.lua @@ -88,12 +88,11 @@ M.add_exec = function(opts) term_mode = { [opts.keymap] = exec_func }, } - local wk_status_ok, wk = pcall(require, "whichkey") + local wk_status_ok, wk = pcall(require, "which-key") if not wk_status_ok then return end wk.register({ [opts.keymap] = { opts.label } }, { mode = "n" }) - wk.register({ [opts.keymap] = { opts.label } }, { mode = "t" }) end M._exec_toggle = function(opts) diff --git a/lua/lvim/core/which-key.lua b/lua/lvim/core/which-key.lua index f169a234..52b7a9ab 100644 --- a/lua/lvim/core/which-key.lua +++ b/lua/lvim/core/which-key.lua @@ -64,6 +64,7 @@ M.config = function() ["/"] = { "<ESC><CMD>lua require('Comment.api').toggle_linewise_op(vim.fn.visualmode())<CR>", "Comment" }, }, mappings = { + [";"] = { "<cmd>Alpha<CR>", "Dashboard" }, ["w"] = { "<cmd>w!<CR>", "Save" }, ["q"] = { "<cmd>q!<CR>", "Quit" }, ["/"] = { "<cmd>lua require('Comment.api').toggle_current_linewise()<CR>", "Comment" }, @@ -167,6 +168,7 @@ M.config = function() "<cmd>Telescope lsp_dynamic_workspace_symbols<cr>", "Workspace Symbols", }, + e = { "<cmd>Telescope quickfix<cr>", "Telescope Quickfix" }, }, L = { name = "+LunarVim", diff --git a/lua/lvim/lsp/config.lua b/lua/lvim/lsp/config.lua index 72a1941f..ca6f66bb 100644 --- a/lua/lvim/lsp/config.lua +++ b/lua/lvim/lsp/config.lua @@ -83,6 +83,7 @@ return { "psalm", "pylsp", "quick_lint_js", + "reason_ls", "remark_ls", "rome", "scry", diff --git a/lua/lvim/lsp/peek.lua b/lua/lvim/lsp/peek.lua index f006f934..eb774a77 100644 --- a/lua/lvim/lsp/peek.lua +++ b/lua/lvim/lsp/peek.lua @@ -32,8 +32,13 @@ local function create_floating_file(location, opts) math.min(range["end"].line + 1 + (opts.context or 10), range.start.line + (opts.max_height or 15)), -- Don't let the window be more that 15 lines long(height) false ) + if next(contents) == nil then + vim.notify("peek: Unable to get contents of the file!", vim.log.levels.WARN) + return + end local width, height = vim.lsp.util._make_floating_popup_size(contents, opts) - opts = vim.lsp.util.make_floating_popup_options(width, height, opts) + local if_nil = vim.F.if_nil + opts = vim.lsp.util.make_floating_popup_options(if_nil(width, 30), if_nil(height, 10), opts) -- Don't make it minimal as it is meant to be fully featured opts["style"] = nil @@ -81,7 +86,7 @@ function M.open_file() local filepath = vim.fn.expand "%:." if not filepath then - print "peek: Unable to open the file!" + vim.notify("peek: Unable to open the file!", vim.log.levels.ERROR) return end @@ -114,7 +119,7 @@ function M.Peek(what) if vim.tbl_contains(vim.api.nvim_list_wins(), M.floating_win) then local success_1, _ = pcall(vim.api.nvim_set_current_win, M.floating_win) if not success_1 then - print "peek: You cannot edit the current file in a preview!" + vim.notify("peek: You cannot edit the current file in a preview!", vim.log.levels.ERROR) return end @@ -134,8 +139,9 @@ function M.Peek(what) local preview_callback = preview_location_callback_new_signature local success, _ = pcall(vim.lsp.buf_request, 0, "textDocument/" .. what, params, preview_callback) if not success then - print( - 'peek: Error calling LSP method "textDocument/' .. what .. '". The current language lsp might not support it.' + vim.notify( + 'peek: Error calling LSP method "textDocument/' .. what .. '". The current language lsp might not support it.', + vim.log.levels.ERROR ) end end diff --git a/lua/lvim/plugin-loader.lua b/lua/lvim/plugin-loader.lua index 0fbe9971..5208d5bf 100644 --- a/lua/lvim/plugin-loader.lua +++ b/lua/lvim/plugin-loader.lua @@ -88,15 +88,14 @@ function plugin_loader.load(configurations) end end end) + -- colorscheme must get called after plugins are loaded or it will break new installs. + vim.g.colors_name = lvim.colorscheme + vim.cmd("colorscheme " .. lvim.colorscheme) end, debug.traceback) if not status_ok then Log:warn "problems detected while loading plugins' configurations" Log:trace(debug.traceback()) end - - -- Colorscheme must get called after plugins are loaded or it will break new installs. - vim.g.colors_name = lvim.colorscheme - vim.cmd("colorscheme " .. lvim.colorscheme) end function plugin_loader.get_core_plugins() diff --git a/lua/lvim/plugins.lua b/lua/lvim/plugins.lua index bd788f1d..d7ecdccb 100644 --- a/lua/lvim/plugins.lua +++ b/lua/lvim/plugins.lua @@ -1,40 +1,41 @@ local commit = { - bufferline = "871495d9e2dbe3314a421fd2d5e46f47de7ee537", + alpha_nvim = "14be0ac200f44009672046123c6fcb30724018a5", + bufferline = "5e101b1b4e1ea5b868b8865a5f749b0b5b8f3ccd", cmp_buffer = "d66c4c2d376e5be99db68d2362cd94d250987525", cmp_luasnip = "d6f837f4e8fe48eeae288e638691b91b97d1737f", cmp_nvim_lsp = "ebdfc204afb87f15ce3d3d3f5df0b8181443b5ba", cmp_path = "466b6b8270f7ba89abd59f402c73f63c7331ff6e", - comment = "00ed8f612b7bcbaf9df870781ed372ee8c00d6a8", + comment = "a841f73523440c4f32d39f0290cf1e691311db2a", dapinstall = "24923c3819a450a772bb8f675926d530e829665f", - dashboard_nvim = "d82ddae95fd4dc4c3b7bbe87f09b1840fbf20ecb", fixcursorhold = "1bfb32e7ba1344925ad815cb0d7f901dbc0ff7c1", friendly_snippets = "ad07b2844021b20797adda5b483265802559a693", - gitsigns = "779f4eb59047ef7faa41e71d261d041edfabfb39", + gitsigns = "2df360de757c39c04076cb04bcbbd361dec3c8c2", lua_dev = "a0ee77789d9948adce64d98700cc90cecaef88d5", - lualine = "d2e0ac595b8e315b454f4384edb2eba7807a8401", - luasnip = "3d544b66c0ded7c01151559a83bd3ff9be6a40e8", - nlsp_settings = "61d95800be78ecea8e16297f36fef52c412d3602", - null_ls = "15d3aabc2b440293ecf6c85f25ca9fa645a468ae", - nvim_autopairs = "d2cde7c5802b34d6391a8a3555a3b7b56482f2aa", - nvim_cmp = "1001683bee3a52a7b7e07ba9d391472961739c7b", - nvim_dap = "edb22a824e33f5244c98dbaa91f749f0d6390a94", - nvim_lsp_installer = "6e6d75b7a446a13ec2bdaaf7934c071936ad3d8c", - nvim_lspconfig = "cf2fc1d5149dc097e8c02c607f0f0c97c5099ae8", + lualine = "181b14348f513e6f9eb3bdd2252e13630094fdd3", + luasnip = "ee350179f842699a42b3d6277b2ded8ce73bdc33", + nlsp_settings = "ea9b88e289359843c3cc5bfbf42e5ed9cc3df5f2", + null_ls = "041601cb03daa8982c5af6edc6641f4b97e9d6b5", + nvim_autopairs = "6617498bea01c9c628406d7e23030da57f2f8718", + nvim_cmp = "71d7f46b930bf08e982925c77bd9b0a9808c1162", + nvim_dap = "3d0575a777610b364fea745b85ad497d56b8009a", + nvim_lsp_installer = "dc783087bef65cc7c2943d8641ff1b6dfff6e5a9", + nvim_lspconfig = "710deb04d9f8b73517e1d995a57a1505cbbaac51", nvim_notify = "f81b48d298c0ff7479b66568d9cc1a4794c196d0", - nvim_tree = "ac858a28a2ca673bbca74af005442e58e015f19e", - nvim_treesitter = "cada76c4901e2389c0f82ac11d0c9c61d5205e90", + nvim_tree = "20797a8d74e68bce50b98455c76c5de250c6f0e5", + nvim_treesitter = "fd92e70c69330dd8f2f6753d3d987c34e7dacd24", nvim_ts_context_commentstring = "097df33c9ef5bbd3828105e4bee99965b758dc3f", nvim_web_devicons = "4415d1aaa56f73b9c05795af84d625c610b05d3b", + onedarker = "b00dd2189f264c5aeb4cf04c59439655ecd573ec", packer = "c576ab3f1488ee86d60fd340d01ade08dcabd256", plenary = "14dfb4071022b22e08384ee125a5607464b6d397", popup = "b7404d35d5d3548a82149238289fa71f7f6de4ac", project = "cef52b8da07648b750d7f1e8fb93f12cb9482988", - schemastore = "120e95a9e3d60a7410adb1be102268091ed400fb", + schemastore = "265eabf9f8ab33cc6bf1683c286b04e280a2b2e7", structlog = "6f1403a192791ff1fa7ac845a73de9e860f781f1", - telescope = "b501d9ecb7d8181e2238620c919740025e8b2096", + telescope = "a36a813d5d031e6f5d52b74986915e68130febd9", telescope_fzf_native = "8ec164b541327202e5e74f99bcc5fe5845720e18", toggleterm = "e97d0c1046512e975a9f3fa95afe98f312752b1c", - which_key = "28d2bd129575b5e9ebddd88506601290bb2bb221", + which_key = "a3c19ec5754debb7bf38a8404e36a9287b282430", } return { @@ -52,13 +53,22 @@ return { commit = commit.nvim_lsp_installer, }, { + "lunarvim/onedarker.nvim", + config = function() + require("onedarker").setup() + lvim.builtin.lualine.options.theme = "onedarker" + end, + commit = commit.onedarker, + disable = lvim.colorscheme ~= "onedarker", + }, + { "rcarriga/nvim-notify", commit = commit.nvim_notify, - disable = not lvim.builtin.notify.active, config = function() require("lvim.core.notify").setup() end, - event = "BufRead", + requires = { "nvim-telescope/telescope.nvim" }, + disable = not lvim.builtin.notify.active or not lvim.builtin.telescope.active, }, { "Tastyep/structlog.nvim", commit = commit.structlog }, @@ -75,6 +85,7 @@ return { }, { "nvim-telescope/telescope-fzf-native.nvim", + requires = { "nvim-telescope/telescope.nvim" }, commit = commit.telescope_fzf_native, run = "make", disable = not lvim.builtin.telescope.active, @@ -253,14 +264,14 @@ return { disable = not lvim.builtin.dap.active, }, - -- Dashboard + -- alpha { - "ChristianChiarulli/dashboard-nvim", - event = "BufWinEnter", + "goolord/alpha-nvim", config = function() - require("lvim.core.dashboard").setup() + require("lvim.core.alpha").setup() end, - disable = not lvim.builtin.dashboard.active, + commit = commit.alpha_nvim, + disable = not lvim.builtin.alpha.active, }, -- Terminal diff --git a/lua/lvim/utils/git.lua b/lua/lvim/utils/git.lua index 8f25a2bb..ce323160 100644 --- a/lua/lvim/utils/git.lua +++ b/lua/lvim/utils/git.lua @@ -1,11 +1,12 @@ local M = {} local Log = require "lvim.core.log" +local if_nil = vim.F.if_nil local function git_cmd(opts) local plenary_loaded, Job = pcall(require, "plenary.job") if not plenary_loaded then - vim.cmd "packadd plenary.nvim" + return 1, { "" } end opts = opts or {} @@ -89,51 +90,27 @@ end ---Get the current Lunarvim development branch ---@return string|nil function M.get_lvim_branch() - local ret, branch = git_cmd { args = { "rev-parse", "--abbrev-ref", "HEAD" } } - if ret ~= 0 or (not branch or branch[1] == "") then - Log:error "Unable to retrieve the name of the current branch. Check the log for further information" - return - end - return branch[1] + local _, results = git_cmd { args = { "rev-parse", "--abbrev-ref", "HEAD" } } + local branch = if_nil(results[1], "") + return branch end ---Get currently checked-out tag of Lunarvim ----@param type string can be "short" ----@return string|nil -function M.get_lvim_tag(type) - type = type or "" - local ret, results = git_cmd { args = { "describe", "--tags" } } - local lvim_full_ver = results[1] or "" +---@return string +function M.get_lvim_tag() + local args = { "describe", "--tags", "--abbrev=0" } - if ret ~= 0 or string.match(lvim_full_ver, "%d") == nil then - return nil - end - 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 + local _, results = git_cmd { args = args } + local tag = if_nil(results[1], "") + return tag end ---Get the commit hash of currently checked-out commit of Lunarvim ----@param type string can be "short" ---@return string|nil -function M.get_lvim_version(type) - type = type or "" - local branch = M.get_lvim_branch() - if branch == "master" then - 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 +function M.get_lvim_current_sha() + local _, log_results = git_cmd { args = { "log", "--pretty=format:%h", "-1" } } + local abbrev_version = if_nil(log_results[1], "") + return abbrev_version end function M.generate_plugins_sha(output) diff --git a/lua/lvim/utils/hooks.lua b/lua/lvim/utils/hooks.lua index d28123ab..b40f2c23 100644 --- a/lua/lvim/utils/hooks.lua +++ b/lua/lvim/utils/hooks.lua @@ -12,8 +12,10 @@ function M.run_pre_reload() end function M.run_on_packer_complete() - -- manually trigger event to fix colors - vim.cmd [[ doautocmd ColorScheme ]] + if not in_headless then + -- manually trigger event to fix colors + vim.cmd [[ doautocmd ColorScheme ]] + end Log:info "Reloaded configuration" end |