diff options
Diffstat (limited to 'lua/lvim/core')
30 files changed, 1297 insertions, 322 deletions
| diff --git a/lua/lvim/core/alpha.lua b/lua/lvim/core/alpha.lua index fd637818..58b787ed 100644 --- a/lua/lvim/core/alpha.lua +++ b/lua/lvim/core/alpha.lua @@ -65,7 +65,10 @@ local function configure_additional_autocmds()  end  function M.setup() -  local alpha = require "alpha" +  local status_ok, alpha = pcall(require, "alpha") +  if not status_ok then +    return +  end    local mode = lvim.builtin.alpha.mode    local config = lvim.builtin.alpha[mode].config diff --git a/lua/lvim/core/alpha/dashboard.lua b/lua/lvim/core/alpha/dashboard.lua index d65980fb..5e73206f 100644 --- a/lua/lvim/core/alpha/dashboard.lua +++ b/lua/lvim/core/alpha/dashboard.lua @@ -1,32 +1,86 @@  local M = {} +local banner = { +  "                ⢀⣀⣤⣤⣤⣶⣶⣶⣶⣶⣶⣤⣤⣤⣀⡀                ", +  "             ⣀⣤⣶⣿⠿⠟⠛⠉⠉⠉⠁⠈⠉⠉⠉⠛⠛⠿⣿⣷⣦⣀             ", +  "          ⢀⣤⣾⡿⠛⠉                ⠉⠛⢿⣷⣤⡀          ", +  "         ⣴⣿⡿⠃                      ⠙⠻⣿⣦         ", +  " ⢀⣠⣤⣤⣤⣤⣤⣾⣿⣉⣀⡀                        ⠙⢻⣷⡄       ", +  "⣼⠋⠁   ⢠⣿⡟ ⠉⠉⠉⠛⠛⠶⠶⣤⣄⣀    ⣀⣀      ⢠⣤⣤⡄   ⢻⣿⣆      ", +  "⢻⡄   ⢰⣿⡟        ⢠⣿⣿⣿⠉⠛⠲⣾⣿⣿⣷    ⢀⣾⣿⣿⠁    ⢻⣿⡆     ", +  " ⠹⣦⡀ ⣿⣿⠁        ⢸⣿⣿⡇   ⠻⣿⣿⠟⠳⠶⣤⣀⣸⣿⣿⠇      ⣿⣷     ", +  "   ⠙⢷⣿⡇         ⣸⣿⣿⠃          ⢸⣿⣿⢷⣤⡀     ⢸⣿⡆    ", +  "    ⢸⣿⠇         ⣿⣿⣿     ⣿⣿⣷  ⢠⣿⣿⡏ ⠈⠙⠳⢦⣄  ⠈⣿⡇    ", +  "    ⢸⣿⡆        ⢸⣿⣿⡇     ⣿⣿⣿ ⢀⣿⣿⡟      ⠈⠙⠷⣤⣿⡇    ", +  "    ⠘⣿⡇        ⣼⣿⣿⠁     ⣿⣿⣿ ⣼⣿⣿⠃         ⢸⣿⠷⣄⡀  ", +  "     ⣿⣿        ⣿⣿⡿      ⣿⣿⣿⢸⣿⣿⠃          ⣾⡿ ⠈⠻⣆ ", +  "     ⠸⣿⣧      ⢸⣿⣿⣇⣀⣀⣀⣀⣀⣀⣸⣿⣿⣿⣿⠇          ⣼⣿⠇   ⠘⣧", +  "      ⠹⣿⣧     ⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠏          ⣼⣿⠏    ⣠⡿", +  "       ⠘⢿⣷⣄   ⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉         ⢠⣼⡿⠛⠛⠛⠛⠛⠛⠉ ", +  "         ⠻⣿⣦⣄                      ⣀⣴⣿⠟         ", +  "          ⠈⠛⢿⣶⣤⣀                ⣀⣤⣶⡿⠛⠁          ", +  "             ⠉⠻⢿⣿⣶⣤⣤⣀⣀⡀  ⢀⣀⣀⣠⣤⣶⣿⡿⠟⠋             ", +  "                ⠈⠉⠙⠛⠻⠿⠿⠿⠿⠿⠿⠟⠛⠋⠉⠁                ", +} + +M.banner_alt_1 = { +  "⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀", +  "⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀", +  "⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣀⣤⣤⣶⣶⣶⣶⣶⣶⣶⣦⣤⣄⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀", +  "⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⣴⣾⣿⠿⠛⠛⠉⠉⠉⠉⠉⠉⠉⠙⠛⠻⢿⣿⣶⣤⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀", +  "⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣴⣿⠿⠛⠉⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠻⢿⣷⣤⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀", +  "⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣴⣿⠟⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⢿⣿⣦⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀", +  "⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡠⠒⠈⠉⠉⠉⠉⠉⣹⣿⠟⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⢿⣷⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀", +  "⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠸⡀⠀⠀⠀⠀⠀⠀⣰⣿⠏⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⢿⣿⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀", +  "⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠑⢄⠀⠀⠀⠀⢰⣿⠏⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⢿⣿⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀", +  "⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠑⢄⡀⠀⣿⡟⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⣿⣧⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀", +  "⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⢺⣿⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀", +  "⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⠉⠑⠢⢄⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀", +  "⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⣿⡇⠀⠀⠀⠈⠑⠢⠄⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⠢⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀", +  "⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢿⣇⠀⠀⠀⠀⠀⠀⠀⠀⠉⠐⠢⠄⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢰⣿⡟⠀⠈⠑⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀", +  "⠀⠀⠀⠀⠀⠀⢀⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⣿⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠁⠒⠠⠤⣀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣾⣿⠁⠀⠀⢀⣼⣦⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀", +  "⠀⠀⠀⠀⠀⠀⢸⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠹⣷⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠁⠒⠂⠤⠤⠀⣀⡀⠀⠀⠀⣼⣿⠇⠀⠀⢀⣸⣿⡿⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀", +  "⠀⠀⠀⠀⠀⠀⣿⡟⠀⠀⠀⠀⠀⠀⣤⡄⠀⠀⠀⣠⣤⠀⠀⢠⣭⣀⣤⣤⣤⡀⠀⠀⠀⢀⣤⣤⣤⣤⡀⠀⠀⠀⢠⣤⢀⣤⣤⣄⠀⠀⣿⣿⠀⠉⣹⣿⠏⠉⠉⢱⣶⣶⣶⡦⠀⠀⠀⢠⣶⣦⣴⣦⣠⣴⣦⡀⠀⠀⠀⠀", +  "⠀⠀⠀⠀⠀⢠⣿⡇⠀⠀⠀⠀⠀⢠⣿⠇⠀⠀⠀⣿⡇⠀⠀⣿⡿⠉⠀⠈⣿⣧⠀⠀⠰⠿⠋⠀⠀⢹⣿⠀⠀⠀⣿⡿⠋⠀⠹⠿⠀⠀⢻⣿⡇⢠⣿⡟⠀⠀⠀⠈⠉⢹⣿⡇⠀⠀⠀⢸⣿⡏⢹⣿⡏⢹⣿⡇⠀⠀⠀⠀", +  "⠀⠀⠀⠀⠀⢸⣿⠀⠀⠀⠀⠀⠀⢸⣿⠀⠀⠀⢰⣿⠃⠀⢠⣿⡇⠀⠀⠀⣿⡇⠀⠀⣠⣴⡶⠶⠶⣿⣿⠀⠀⢠⣿⡇⠀⠀⠀⠀⠀⠀⢸⣿⣇⣿⡿⠀⠀⠀⠀⠀⠀⣿⣿⠁⠀⠀⠀⣿⣿⠀⣾⣿⠀⣾⣿⠁⠀⠀⠀⠀", +  "⠀⠀⠀⠀⠀⣿⣟⠀⠀⠀⠀⠀⠀⢻⣿⡀⠀⢀⣼⣿⠀⠀⢸⣿⠀⠀⠀⢰⣿⠇⠀⢰⣿⣇⠀⠀⣠⣿⡏⠀⠀⢸⣿⠀⠀⠀⠀⠀⠀⠀⢸⣿⣿⣿⠁⠀⠀⠀⣀⣀⣠⣿⣿⣀⡀⠀⢠⣿⡟⢠⣿⡟⢀⣿⡿⠀⠀⠀⠀⠀", +  "⠀⠀⠀⠀⠀⠛⠛⠛⠛⠛⠛⠁⠀⠈⠛⠿⠟⠋⠛⠃⠀⠀⠛⠛⠀⠀⠀⠘⠛⠀⠀⠀⠙⠿⠿⠛⠙⠛⠃⠀⠀⠚⠛⠀⠀⠀⠀⠀⠀⠀⠘⠿⠿⠃⠀⠀⠀⠀⠿⠿⠿⠿⠿⠿⠿⠀⠸⠿⠇⠸⠿⠇⠸⠿⠇⠀⠀⠀⠀⠀", +  "                                                                                ", +} + +M.banner_alt_2 = { +  "⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿", +  "⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠿⠟⠛⠛⠉⠉⠉⠉⠉⠉⠛⠛⠻⠿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿", +  "⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠿⠛⠉⠀⣀⣤⣴⣶⣶⣾⣿⣿⣷⣶⣶⣦⣤⣀⠀⠉⠛⠿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿", +  "⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠟⠁⢀⣴⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣦⡀⠈⠻⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿", +  "⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠏⠀⣠⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣄⠀⠹⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿", +  "⣿⣿⠿⠟⠛⠛⠛⠛⠛⠁⠀⠾⠿⠿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⡀⠈⢻⣿⣿⣿⣿⣿⣿⣿⣿", +  "⣿⠁⣴⣾⣿⣿⣿⡟⠀⣰⣿⣶⣶⣶⣤⣤⣉⣉⠛⠛⠿⠿⣿⣿⡿⠿⠿⣿⣿⣿⣿⣿⣿⡟⠛⠛⢛⣿⣿⣿⣆⠀⢻⣿⣿⣿⣿⣿⣿⣿", +  "⣿⡄⠻⣿⣿⣿⡟⠀⢠⣿⣿⣿⣿⣿⣿⣿⣿⡟⠀⠀⠀⣦⣤⡈⠀⠀⠀⠈⣿⣿⣿⣿⡿⠁⠀⠀⣾⣿⣿⣿⣿⡄⠀⢻⣿⣿⣿⣿⣿⣿", +  "⣿⣿⣄⠙⠿⣿⠁⢀⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⠀⠀⢸⣿⣿⣿⣄⠀⠀⣠⣄⣉⠛⠻⠃⠀⠀⣼⣿⣿⣿⣿⣿⣿⡀⠈⣿⣿⣿⣿⣿⣿", +  "⣿⣿⣿⣷⣦⡈⠀⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⠀⠀⠀⣼⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠆⠀⠀⡀⠛⠿⣿⣿⣿⣿⣿⡇⠀⢻⣿⣿⣿⣿⣿", +  "⣿⣿⣿⣿⣿⡇⠀⣾⣿⣿⣿⣿⣿⣿⣿⣿⡟⠀⠀⢀⣿⣿⣿⣿⡇⠀⠀⠘⣿⣿⡟⠀⠀⢰⣿⣷⣦⣌⡙⠻⢿⣿⣷⠀⢸⣿⣿⣿⣿⣿", +  "⣿⣿⣿⣿⣿⡇⠀⢿⣿⣿⣿⣿⣿⣿⣿⣿⡇⠀⠀⢸⣿⣿⣿⣿⣿⠀⠀⠀⣿⡿⠀⠀⢀⣿⣿⣿⣿⣿⣿⣷⣤⣈⠛⠀⢸⣿⣿⣿⣿⣿", +  "⣿⣿⣿⣿⣿⣧⠀⢸⣿⣿⣿⣿⣿⣿⣿⣿⠁⠀⠀⣾⣿⣿⣿⣿⣿⠀⠀⠀⣿⠁⠀⠀⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⠀⡈⠻⢿⣿⣿⣿", +  "⣿⣿⣿⣿⣿⣿⡀⠈⣿⣿⣿⣿⣿⣿⣿⡿⠀⠀⢀⣿⣿⣿⣿⣿⣿⠀⠀⠀⠃⠀⠀⣼⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠁⢀⣿⣶⣄⠙⣿⣿", +  "⣿⣿⣿⣿⣿⣿⣧⠀⠘⣿⣿⣿⣿⣿⣿⡇⠀⠀⠸⠿⠿⠿⠿⠿⠿⠇⠀⠀⠀⠀⣸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠃⠀⣼⣿⣿⣿⣦⠘⣿", +  "⣿⣿⣿⣿⣿⣿⣿⣧⠀⠹⣿⣿⣿⣿⣿⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢰⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠏⠀⣼⣿⣿⣿⡿⠟⢀⣿", +  "⣿⣿⣿⣿⣿⣿⣿⣿⣧⡀⠈⢿⣿⣿⣿⣶⣶⣶⣶⣶⣶⣶⣶⣶⣶⣶⣶⣶⣶⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠁⢀⣤⣤⣤⣤⣤⣴⣶⣿⣿", +  "⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣆⠀⠙⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠋⠀⣰⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿", +  "⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣦⡀⠈⠻⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠟⠁⢀⣴⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿", +  "⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣶⣤⣀⠀⠉⠛⠻⠿⠿⢿⣿⣿⡿⠿⠿⠟⠛⠉⠀⣀⣤⣶⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿", +  "⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣶⣦⣤⣤⣀⣀⣀⣀⣀⣀⣤⣤⣴⣶⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿", +  "⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿", +} + +if vim.o.lines < 36 then +  banner = vim.list_slice(banner, 16, 22) +end +  function M.get_sections()    local header = {      type = "text", -    val = { -      "⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀", -      "⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀", -      "⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣀⣤⣤⣶⣶⣶⣶⣶⣶⣶⣦⣤⣄⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀", -      "⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⣴⣾⣿⠿⠛⠛⠉⠉⠉⠉⠉⠉⠉⠙⠛⠻⢿⣿⣶⣤⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀", -      "⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣴⣿⠿⠛⠉⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠻⢿⣷⣤⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀", -      "⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣴⣿⠟⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⢿⣿⣦⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀", -      "⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡠⠒⠈⠉⠉⠉⠉⠉⣹⣿⠟⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⢿⣷⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀", -      "⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠸⡀⠀⠀⠀⠀⠀⠀⣰⣿⠏⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⢿⣿⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀", -      "⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠑⢄⠀⠀⠀⠀⢰⣿⠏⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⢿⣿⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀", -      "⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠑⢄⡀⠀⣿⡟⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⣿⣧⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀", -      "⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⢺⣿⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀", -      "⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⠉⠑⠢⢄⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀", -      "⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⣿⡇⠀⠀⠀⠈⠑⠢⠄⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⠢⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀", -      "⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢿⣇⠀⠀⠀⠀⠀⠀⠀⠀⠉⠐⠢⠄⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢰⣿⡟⠀⠈⠑⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀", -      "⠀⠀⠀⠀⠀⠀⢀⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⣿⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠁⠒⠠⠤⣀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣾⣿⠁⠀⠀⢀⣼⣦⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀", -      "⠀⠀⠀⠀⠀⠀⢸⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠹⣷⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠁⠒⠂⠤⠤⠀⣀⡀⠀⠀⠀⣼⣿⠇⠀⠀⢀⣸⣿⡿⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀", -      "⠀⠀⠀⠀⠀⠀⣿⡟⠀⠀⠀⠀⠀⠀⣤⡄⠀⠀⠀⣠⣤⠀⠀⢠⣭⣀⣤⣤⣤⡀⠀⠀⠀⢀⣤⣤⣤⣤⡀⠀⠀⠀⢠⣤⢀⣤⣤⣄⠀⠀⣿⣿⠀⠉⣹⣿⠏⠉⠉⢱⣶⣶⣶⡦⠀⠀⠀⢠⣶⣦⣴⣦⣠⣴⣦⡀⠀⠀⠀⠀", -      "⠀⠀⠀⠀⠀⢠⣿⡇⠀⠀⠀⠀⠀⢠⣿⠇⠀⠀⠀⣿⡇⠀⠀⣿⡿⠉⠀⠈⣿⣧⠀⠀⠰⠿⠋⠀⠀⢹⣿⠀⠀⠀⣿⡿⠋⠀⠹⠿⠀⠀⢻⣿⡇⢠⣿⡟⠀⠀⠀⠈⠉⢹⣿⡇⠀⠀⠀⢸⣿⡏⢹⣿⡏⢹⣿⡇⠀⠀⠀⠀", -      "⠀⠀⠀⠀⠀⢸⣿⠀⠀⠀⠀⠀⠀⢸⣿⠀⠀⠀⢰⣿⠃⠀⢠⣿⡇⠀⠀⠀⣿⡇⠀⠀⣠⣴⡶⠶⠶⣿⣿⠀⠀⢠⣿⡇⠀⠀⠀⠀⠀⠀⢸⣿⣇⣿⡿⠀⠀⠀⠀⠀⠀⣿⣿⠁⠀⠀⠀⣿⣿⠀⣾⣿⠀⣾⣿⠁⠀⠀⠀⠀", -      "⠀⠀⠀⠀⠀⣿⣟⠀⠀⠀⠀⠀⠀⢻⣿⡀⠀⢀⣼⣿⠀⠀⢸⣿⠀⠀⠀⢰⣿⠇⠀⢰⣿⣇⠀⠀⣠⣿⡏⠀⠀⢸⣿⠀⠀⠀⠀⠀⠀⠀⢸⣿⣿⣿⠁⠀⠀⠀⣀⣀⣠⣿⣿⣀⡀⠀⢠⣿⡟⢠⣿⡟⢀⣿⡿⠀⠀⠀⠀⠀", -      "⠀⠀⠀⠀⠀⠛⠛⠛⠛⠛⠛⠁⠀⠈⠛⠿⠟⠋⠛⠃⠀⠀⠛⠛⠀⠀⠀⠘⠛⠀⠀⠀⠙⠿⠿⠛⠙⠛⠃⠀⠀⠚⠛⠀⠀⠀⠀⠀⠀⠀⠘⠿⠿⠃⠀⠀⠀⠀⠿⠿⠿⠿⠿⠿⠿⠀⠸⠿⠇⠸⠿⠇⠸⠿⠇⠀⠀⠀⠀⠀", -      "                                                                                ", -    }, +    val = banner,      opts = {        position = "center",        hl = "Label", @@ -48,21 +102,30 @@ function M.get_sections()        hl = "Number",      },    } +  local buttons = {} -  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>", +  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 = "Macro" +      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>" +        ),        }, -    }, -  } +    } +  end    return {      header = header, diff --git a/lua/lvim/core/alpha/startify.lua b/lua/lvim/core/alpha/startify.lua index 2ea541f5..b1e83d1d 100644 --- a/lua/lvim/core/alpha/startify.lua +++ b/lua/lvim/core/alpha/startify.lua @@ -19,7 +19,7 @@ function M.get_sections()    local top_buttons = {      entries = { -      { "e", "  New File", "<CMD>ene!<CR>" }, +      { "e", lvim.icons.ui.NewFile .. " New File", "<CMD>ene!<CR>" },      },      val = {},    } diff --git a/lua/lvim/core/autocmds.lua b/lua/lvim/core/autocmds.lua index f5c63588..ae10d552 100644 --- a/lua/lvim/core/autocmds.lua +++ b/lua/lvim/core/autocmds.lua @@ -3,13 +3,25 @@ local Log = require "lvim.core.log"  --- Load the default set of autogroups and autocommands.  function M.load_defaults() -  local user_config_file = require("lvim.config"):get_user_config_path() - -  if vim.loop.os_uname().version:match "Windows" then -    -- autocmds require forward slashes even on windows -    user_config_file = user_config_file:gsub("\\", "/") -  end - +  vim.api.nvim_create_autocmd({ "FileType" }, { +    pattern = { +      "Jaq", +      "qf", +      "help", +      "man", +      "lspinfo", +      "spectre_panel", +      "lir", +      "DressingSelect", +      "tsplayground", +    }, +    callback = function() +      vim.cmd [[ +      nnoremap <silent> <buffer> q :close<CR> +      set nobuflisted +    ]] +    end, +  })    local definitions = {      {        "TextYankPost", @@ -18,19 +30,16 @@ function M.load_defaults()          pattern = "*",          desc = "Highlight text on yank",          callback = function() -          require("vim.highlight").on_yank { higroup = "Search", timeout = 200 } +          require("vim.highlight").on_yank { higroup = "Search", timeout = 100 }          end,        },      },      { -      "BufWritePost", +      "FileType",        { -        group = "_general_settings", -        pattern = user_config_file, -        desc = "Trigger LvimReload on saving " .. vim.fn.expand "%:~", -        callback = function() -          require("lvim.config"):reload() -        end, +        group = "_hide_dap_repl", +        pattern = "dap-repl", +        command = "set nobuflisted",        },      },      { @@ -73,6 +82,31 @@ function M.load_defaults()          command = "tabdo wincmd =",        },      }, +    { +      "FileType", +      { +        group = "_filetype_settings", +        pattern = "alpha", +        callback = function() +          vim.cmd [[ +            nnoremap <silent> <buffer> q :qa<CR> +            nnoremap <silent> <buffer> <esc> :qa<CR> +            set nobuflisted +          ]] +        end, +      }, +    }, +    { +      "FileType", +      { +        group = "_filetype_settings", +        pattern = "lir", +        callback = function() +          vim.opt_local.number = false +          vim.opt_local.relativenumber = false +        end, +      }, +    },    }    M.define_autocmds(definitions) @@ -129,6 +163,23 @@ function M.toggle_format_on_save()    end  end +function M.enable_reload_config_on_save() +  local user_config_file = require("lvim.config"):get_user_config_path() + +  if vim.loop.os_uname().version:match "Windows" then +    -- autocmds require forward slashes even on windows +    user_config_file = user_config_file:gsub("\\", "/") +  end +  vim.api.nvim_create_autocmd("BufWritePost", { +    group = "_general_settings", +    pattern = user_config_file, +    desc = "Trigger LvimReload on saving config.lua", +    callback = function() +      require("lvim.config"):reload() +    end, +  }) +end +  function M.enable_transparent_mode()    vim.api.nvim_create_autocmd("ColorScheme", {      pattern = "*", diff --git a/lua/lvim/core/autopairs.lua b/lua/lvim/core/autopairs.lua index 469a38a4..5daffba5 100644 --- a/lua/lvim/core/autopairs.lua +++ b/lua/lvim/core/autopairs.lua @@ -47,7 +47,10 @@ function M.config()  end  M.setup = function() -  local autopairs = require "nvim-autopairs" +  local status_ok, autopairs = pcall(require, "nvim-autopairs") +  if not status_ok then +    return +  end    local Rule = require "nvim-autopairs.rule"    autopairs.setup { diff --git a/lua/lvim/core/breadcrumbs.lua b/lua/lvim/core/breadcrumbs.lua new file mode 100644 index 00000000..ab5aa86d --- /dev/null +++ b/lua/lvim/core/breadcrumbs.lua @@ -0,0 +1,226 @@ +local M = {} + +-- local Log = require "lvim.core.log" + +local icons = lvim.icons.kind + +M.config = function() +  lvim.builtin.breadcrumbs = { +    active = true, +    on_config_done = nil, +    winbar_filetype_exclude = { +      "help", +      "startify", +      "dashboard", +      "packer", +      "neo-tree", +      "neogitstatus", +      "NvimTree", +      "Trouble", +      "alpha", +      "lir", +      "Outline", +      "spectre_panel", +      "toggleterm", +      "DressingSelect", +      "Jaq", +      "harpoon", +      "dap-repl", +      "dap-terminal", +      "dapui_console", +      "lab", +      "Markdown", +      "notify", +      "noice", +      "", +    }, +    options = { +      icons = { +        Array = icons.Array .. " ", +        Boolean = icons.Boolean, +        Class = icons.Class .. " ", +        Color = icons.Color .. " ", +        Constant = icons.Constant .. " ", +        Constructor = icons.Constructor .. " ", +        Enum = icons.Enum .. " ", +        EnumMember = icons.EnumMember .. " ", +        Event = icons.Event .. " ", +        Field = icons.Field .. " ", +        File = icons.File .. " ", +        Folder = icons.Folder .. " ", +        Function = icons.Function .. " ", +        Interface = icons.Interface .. " ", +        Key = icons.Key .. " ", +        Keyword = icons.Keyword .. " ", +        Method = icons.Method .. " ", +        Module = icons.Module .. " ", +        Namespace = icons.Namespace .. " ", +        Null = icons.Null .. " ", +        Number = icons.Number .. " ", +        Object = icons.Object .. " ", +        Operator = icons.Operator .. " ", +        Package = icons.Package .. " ", +        Property = icons.Property .. " ", +        Reference = icons.Reference .. " ", +        Snippet = icons.Snippet .. " ", +        String = icons.String .. " ", +        Struct = icons.Struct .. " ", +        Text = icons.Text .. " ", +        TypeParameter = icons.TypeParameter .. " ", +        Unit = icons.Unit .. " ", +        Value = icons.Value .. " ", +        Variable = icons.Variable .. " ", +      }, +      highlight = true, +      separator = " " .. ">" .. " ", +      depth_limit = 0, +      depth_limit_indicator = "..", +    }, +  } +end + +M.setup = function() +  local status_ok, navic = pcall(require, "nvim-navic") +  if not status_ok then +    return +  end + +  M.create_winbar() +  navic.setup(lvim.builtin.breadcrumbs.options) + +  if lvim.builtin.breadcrumbs.on_config_done then +    lvim.builtin.breadcrumbs.on_config_done() +  end +end + +M.get_filename = function() +  local filename = vim.fn.expand "%:t" +  local extension = vim.fn.expand "%:e" +  local f = require "lvim.utils.functions" + +  if not f.isempty(filename) then +    local file_icon, file_icon_color = +      require("nvim-web-devicons").get_icon_color(filename, extension, { default = true }) + +    local hl_group = "FileIconColor" .. extension + +    vim.api.nvim_set_hl(0, hl_group, { fg = file_icon_color }) +    if f.isempty(file_icon) then +      file_icon = lvim.icons.kind.File +    end + +    local buf_ft = vim.bo.filetype + +    if buf_ft == "dapui_breakpoints" then +      file_icon = lvim.icons.ui.Bug +    end + +    if buf_ft == "dapui_stacks" then +      file_icon = lvim.icons.ui.Stacks +    end + +    if buf_ft == "dapui_scopes" then +      file_icon = lvim.icons.ui.Scopes +    end + +    if buf_ft == "dapui_watches" then +      file_icon = lvim.icons.ui.Watches +    end + +    -- if buf_ft == "dapui_console" then +    --   file_icon = lvim.icons.ui.DebugConsole +    -- end + +    local navic_text = vim.api.nvim_get_hl_by_name("Normal", true) +    vim.api.nvim_set_hl(0, "Winbar", { fg = navic_text.foreground }) + +    return " " .. "%#" .. hl_group .. "#" .. file_icon .. "%*" .. " " .. "%#Winbar#" .. filename .. "%*" +  end +end + +local get_gps = function() +  local status_gps_ok, gps = pcall(require, "nvim-navic") +  if not status_gps_ok then +    return "" +  end + +  local status_ok, gps_location = pcall(gps.get_location, {}) +  if not status_ok then +    return "" +  end + +  if not gps.is_available() or gps_location == "error" then +    return "" +  end + +  if not require("lvim.utils.functions").isempty(gps_location) then +    -- TODO: replace with chevron +    return ">" .. " " .. gps_location +  else +    return "" +  end +end + +local excludes = function() +  return vim.tbl_contains(lvim.builtin.breadcrumbs.winbar_filetype_exclude or {}, vim.bo.filetype) +end + +M.get_winbar = function() +  if excludes() then +    return +  end +  local f = require "lvim.utils.functions" +  local value = M.get_filename() + +  local gps_added = false +  if not f.isempty(value) then +    local gps_value = get_gps() +    value = value .. " " .. gps_value +    if not f.isempty(gps_value) then +      gps_added = true +    end +  end + +  if not f.isempty(value) and f.get_buf_option "mod" then +    -- TODO: replace with circle +    local mod = "%#LspCodeLens#" .. lvim.icons.ui.Circle .. "%*" +    if gps_added then +      value = value .. " " .. mod +    else +      value = value .. mod +    end +  end + +  local num_tabs = #vim.api.nvim_list_tabpages() + +  if num_tabs > 1 and not f.isempty(value) then +    local tabpage_number = tostring(vim.api.nvim_tabpage_get_number(0)) +    value = value .. "%=" .. tabpage_number .. "/" .. tostring(num_tabs) +  end + +  local status_ok, _ = pcall(vim.api.nvim_set_option_value, "winbar", value, { scope = "local" }) +  if not status_ok then +    return +  end +end + +M.create_winbar = function() +  vim.api.nvim_create_augroup("_winbar", {}) +  if vim.fn.has "nvim-0.8" == 1 then +    vim.api.nvim_create_autocmd( +      { "CursorMoved", "CursorHold", "BufWinEnter", "BufFilePost", "InsertEnter", "BufWritePost", "TabClosed" }, +      { +        group = "_winbar", +        callback = function() +          local status_ok, _ = pcall(vim.api.nvim_buf_get_var, 0, "lsp_floating_window") +          if not status_ok then +            -- TODO: +            require("lvim.core.breadcrumbs").get_winbar() +          end +        end, +      } +    ) +  end +end + +return M diff --git a/lua/lvim/core/bufferline.lua b/lua/lvim/core/bufferline.lua index 36e5ff54..b8143813 100644 --- a/lua/lvim/core/bufferline.lua +++ b/lua/lvim/core/bufferline.lua @@ -6,7 +6,11 @@ end  local function diagnostics_indicator(num, _, diagnostics, _)    local result = {} -  local symbols = { error = "", warning = "", info = "" } +  local symbols = { +    error = lvim.icons.diagnostics.Error, +    warning = lvim.icons.diagnostics.Warning, +    info = lvim.icons.diagnostics.Information, +  }    if not lvim.use_icons then      return "(" .. num .. ")"    end @@ -59,14 +63,14 @@ M.config = function()        left_mouse_command = "buffer %d", -- can be a string | function, see "Mouse actions"        middle_mouse_command = nil, -- can be a string | function, see "Mouse actions"        indicator = { -        icon = "▎", -- this should be omitted if indicator style is not 'icon' +        icon = lvim.icons.ui.BoldLineLeft, -- this should be omitted if indicator style is not 'icon'          style = "icon", -- can also be 'underline'|'none',        }, -      buffer_close_icon = "", -      modified_icon = "●", -      close_icon = "", -      left_trunc_marker = "", -      right_trunc_marker = "", +      buffer_close_icon = lvim.icons.ui.Close, +      modified_icon = lvim.icons.ui.Circle, +      close_icon = lvim.icons.ui.BoldClose, +      left_trunc_marker = lvim.icons.ui.ArrowCircleLeft, +      right_trunc_marker = lvim.icons.ui.ArrowCircleRight,        --- name_formatter can be used to change the buffer's label in the bufferline.        --- Please note some names can/will break the        --- bufferline so use this at your discretion knowing that it has @@ -140,7 +144,13 @@ end  M.setup = function()    require("lvim.keymappings").load(lvim.builtin.bufferline.keymap) -  require("bufferline").setup { + +  local status_ok, bufferline = pcall(require, "bufferline") +  if not status_ok then +    return +  end + +  bufferline.setup {      options = lvim.builtin.bufferline.options,      highlights = lvim.builtin.bufferline.highlights,    } diff --git a/lua/lvim/core/builtins/init.lua b/lua/lvim/core/builtins/init.lua index 5cad2a00..0060c460 100644 --- a/lua/lvim/core/builtins/init.lua +++ b/lua/lvim/core/builtins/init.lua @@ -1,6 +1,7 @@  local M = {}  local builtins = { +  "lvim.core.theme",    "lvim.core.which-key",    "lvim.core.gitsigns",    "lvim.core.cmp", @@ -9,6 +10,10 @@ local builtins = {    "lvim.core.telescope",    "lvim.core.treesitter",    "lvim.core.nvimtree", +  "lvim.core.lir", +  "lvim.core.illuminate", +  "lvim.core.indentlines", +  "lvim.core.breadcrumbs",    "lvim.core.project",    "lvim.core.bufferline",    "lvim.core.autopairs", @@ -21,7 +26,8 @@ local builtins = {  function M.config(config)    for _, builtin_path in ipairs(builtins) do -    local builtin = require(builtin_path) +    local builtin = reload(builtin_path) +      builtin.config(config)    end  end diff --git a/lua/lvim/core/cmp.lua b/lua/lvim/core/cmp.lua index 408691a6..4ebc4d43 100644 --- a/lua/lvim/core/cmp.lua +++ b/lua/lvim/core/cmp.lua @@ -19,6 +19,7 @@ end  local function feedkeys(key, mode)    vim.api.nvim_feedkeys(T(key), mode, true)  end +  M.methods.feedkeys = feedkeys  ---when inside a snippet, seeks to the nearest luasnip field if possible, and checks if it is jumpable @@ -113,6 +114,7 @@ local function jumpable(dir)      return luasnip.in_snippet() and seek_luasnip_cursor_node() and luasnip.jumpable(1)    end  end +  M.methods.jumpable = jumpable  M.config = function() @@ -135,39 +137,13 @@ M.config = function()        keyword_length = 1,      },      experimental = { -      ghost_text = true, +      ghost_text = false,        native_menu = false,      },      formatting = {        fields = { "kind", "abbr", "menu" },        max_width = 0, -      kind_icons = { -        Class = " ", -        Color = " ", -        Constant = "ﲀ ", -        Constructor = " ", -        Enum = "練", -        EnumMember = " ", -        Event = " ", -        Field = " ", -        File = "", -        Folder = " ", -        Function = " ", -        Interface = "ﰮ ", -        Keyword = " ", -        Method = " ", -        Module = " ", -        Operator = "", -        Property = " ", -        Reference = " ", -        Snippet = " ", -        Struct = " ", -        Text = " ", -        TypeParameter = " ", -        Unit = "塞", -        Value = " ", -        Variable = " ", -      }, +      kind_icons = lvim.icons.kind,        source_names = {          nvim_lsp = "(LSP)",          emoji = "(Emoji)", @@ -178,6 +154,8 @@ M.config = function()          luasnip = "(Snippet)",          buffer = "(Buffer)",          tmux = "(TMUX)", +        copilot = "(Copilot)", +        treesitter = "(TreeSitter)",        },        duplicates = {          buffer = 1, @@ -189,10 +167,40 @@ M.config = function()        format = function(entry, vim_item)          local max_width = lvim.builtin.cmp.formatting.max_width          if max_width ~= 0 and #vim_item.abbr > max_width then -          vim_item.abbr = string.sub(vim_item.abbr, 1, max_width - 1) .. "…" +          vim_item.abbr = string.sub(vim_item.abbr, 1, max_width - 1) .. lvim.icons.ui.Ellipsis          end          if lvim.use_icons then            vim_item.kind = lvim.builtin.cmp.formatting.kind_icons[vim_item.kind] + +          -- TODO: not sure why I can't put this anywhere else +          vim.api.nvim_set_hl(0, "CmpItemKindCopilot", { fg = "#6CC644" }) +          if entry.source.name == "copilot" then +            vim_item.kind = lvim.icons.git.Octoface +            vim_item.kind_hl_group = "CmpItemKindCopilot" +          end + +          vim.api.nvim_set_hl(0, "CmpItemKindTabnine", { fg = "#CA42F0" }) +          if entry.source.name == "cmp_tabnine" then +            vim_item.kind = lvim.icons.misc.Robot +            vim_item.kind_hl_group = "CmpItemKindTabnine" +          end + +          vim.api.nvim_set_hl(0, "CmpItemKindCrate", { fg = "#F64D00" }) +          if entry.source.name == "crates" then +            vim_item.kind = lvim.icons.misc.Package +            vim_item.kind_hl_group = "CmpItemKindCrate" +          end + +          if entry.source.name == "lab.quick_data" then +            vim_item.kind = lvim.icons.misc.CircuitBoard +            vim_item.kind_hl_group = "CmpItemKindConstant" +          end + +          vim.api.nvim_set_hl(0, "CmpItemKindEmoji", { fg = "#FDE030" }) +          if entry.source.name == "emoji" then +            vim_item.kind = lvim.icons.misc.Smiley +            vim_item.kind_hl_group = "CmpItemKindEmoji" +          end          end          vim_item.menu = lvim.builtin.cmp.formatting.source_names[entry.source.name]          vim_item.dup = lvim.builtin.cmp.formatting.duplicates[entry.source.name] @@ -210,7 +218,50 @@ M.config = function()        documentation = cmp.config.window.bordered(),      },      sources = { -      { name = "nvim_lsp" }, +      { +        name = "copilot", +        -- keyword_length = 0, +        max_item_count = 3, +        trigger_characters = { +          { +            ".", +            ":", +            "(", +            "'", +            '"', +            "[", +            ",", +            "#", +            "*", +            "@", +            "|", +            "=", +            "-", +            "{", +            "/", +            "\\", +            "+", +            "?", +            " ", +            -- "\t", +            -- "\n", +          }, +        }, +      }, +      { +        name = "nvim_lsp", +        entry_filter = function(entry, ctx) +          local kind = require("cmp.types").lsp.CompletionItemKind[entry:get_kind()] +          if kind == "Snippet" and ctx.prev_context.filetype == "java" then +            return false +          end +          if kind == "Text" then +            return false +          end +          return true +        end, +      }, +        { name = "path" },        { name = "luasnip" },        { name = "cmp_tabnine" }, @@ -223,8 +274,8 @@ M.config = function()        { name = "tmux" },      },      mapping = cmp.mapping.preset.insert { -      ["<C-k>"] = cmp.mapping.select_prev_item(), -      ["<C-j>"] = cmp.mapping.select_next_item(), +      ["<C-k>"] = cmp.mapping(cmp.mapping.select_prev_item(), { "i", "c" }), +      ["<C-j>"] = cmp.mapping(cmp.mapping.select_next_item(), { "i", "c" }),        ["<Down>"] = cmp.mapping(cmp.mapping.select_next_item { behavior = cmp.SelectBehavior.Select }, { "i" }),        ["<Up>"] = cmp.mapping(cmp.mapping.select_prev_item { behavior = cmp.SelectBehavior.Select }, { "i" }),        ["<C-d>"] = cmp.mapping.scroll_docs(-4), @@ -247,7 +298,8 @@ M.config = function()          elseif jumpable(1) then            luasnip.jump(1)          elseif has_words_before() then -          cmp.complete() +          -- cmp.complete() +          fallback()          else            fallback()          end @@ -283,11 +335,38 @@ M.config = function()          fallback() -- if not exited early, always fallback        end),      }, +    cmdline = { +      enable = true, +      options = { +        { +          type = ":", +          sources = { +            { name = "path" }, +          }, +        }, +        { +          type = { "/", "?" }, +          sources = { +            { name = "buffer" }, +          }, +        }, +      }, +    },    }  end  function M.setup() -  require("cmp").setup(lvim.builtin.cmp) +  local cmp = require "cmp" +  cmp.setup(lvim.builtin.cmp) + +  if lvim.builtin.cmp.cmdline.enable then +    for _, option in ipairs(lvim.builtin.cmp.cmdline.options) do +      cmp.setup.cmdline(option.type, { +        mapping = cmp.mapping.preset.cmdline(), +        sources = option.sources, +      }) +    end +  end  end  return M diff --git a/lua/lvim/core/comment.lua b/lua/lvim/core/comment.lua index d07739c6..501d01b6 100644 --- a/lua/lvim/core/comment.lua +++ b/lua/lvim/core/comment.lua @@ -1,27 +1,10 @@  local M = {}  function M.config() -  local pre_hook = nil -  if lvim.builtin.treesitter.context_commentstring.enable then -    pre_hook = function(ctx) -      local U = require "Comment.utils" - -      -- Determine whether to use linewise or blockwise commentstring -      local type = ctx.ctype == U.ctype.linewise and "__default" or "__multiline" - -      -- Determine the location where to calculate commentstring from -      local location = nil -      if ctx.ctype == U.ctype.blockwise then -        location = require("ts_context_commentstring.utils").get_cursor_location() -      elseif ctx.cmotion == U.cmotion.v or ctx.cmotion == U.cmotion.V then -        location = require("ts_context_commentstring.utils").get_visual_start_location() -      end - -      return require("ts_context_commentstring.internal").calculate_commentstring { -        key = type, -        location = location, -      } -    end +  local pre_hook +  local loaded, ts_comment = pcall(require, "ts_context_commentstring.integrations.comment_nvim") +  if loaded and ts_comment then +    pre_hook = ts_comment.create_pre_hook()    end    lvim.builtin.comment = {      active = true, @@ -30,6 +13,11 @@ function M.config()      ---@type boolean      padding = true, +    ---Whether cursor should stay at the +    ---same position. Only works in NORMAL +    ---mode mappings +    sticky = true, +      ---Lines to be ignored while comment/uncomment.      ---Could be a regex string or a function that returns a regex string.      ---Example: Use '^$' to ignore empty lines @@ -45,9 +33,6 @@ function M.config()        ---Extra mapping        ---Includes `gco`, `gcO`, `gcA`        extra = true, -      ---Extended mapping -      ---Includes `g>`, `g<`, `g>[count]{motion}` and `g<[count]{motion}` -      extended = false,      },      ---LHS of line and block comment toggle mapping in NORMAL/VISUAL mode @@ -68,6 +53,17 @@ function M.config()        block = "gb",      }, +    ---LHS of extra mappings +    ---@type table +    extra = { +      ---Add comment on the line above +      above = "gcO", +      ---Add comment on the line below +      below = "gco", +      ---Add comment at the end of line +      eol = "gcA", +    }, +      ---Pre-hook, called before commenting the line      ---@type function|nil      pre_hook = pre_hook, diff --git a/lua/lvim/core/dap.lua b/lua/lvim/core/dap.lua index 727e238f..cff50f64 100644 --- a/lua/lvim/core/dap.lua +++ b/lua/lvim/core/dap.lua @@ -2,31 +2,37 @@ local M = {}  M.config = function()    lvim.builtin.dap = { -    active = false, +    active = true,      on_config_done = nil,      breakpoint = { -      text = "", -      texthl = "LspDiagnosticsSignError", +      text = lvim.icons.ui.Bug, +      texthl = "DiagnosticSignError",        linehl = "",        numhl = "",      },      breakpoint_rejected = { -      text = "", -      texthl = "LspDiagnosticsSignHint", +      text = lvim.icons.ui.Bug, +      texthl = "DiagnosticSignError",        linehl = "",        numhl = "",      },      stopped = { -      text = "", -      texthl = "LspDiagnosticsSignInformation", -      linehl = "DiagnosticUnderlineInfo", -      numhl = "LspDiagnosticsSignInformation", +      text = lvim.icons.ui.BoldArrowRight, +      texthl = "DiagnosticSignWarn", +      linehl = "Visual", +      numhl = "DiagnosticSignWarn", +    }, +    ui = { +      auto_open = true,      },    }  end  M.setup = function() -  local dap = require "dap" +  local status_ok, dap = pcall(require, "dap") +  if not status_ok then +    return +  end    if lvim.use_icons then      vim.fn.sign_define("DapBreakpoint", lvim.builtin.dap.breakpoint) @@ -34,8 +40,6 @@ M.setup = function()      vim.fn.sign_define("DapStopped", lvim.builtin.dap.stopped)    end -  dap.defaults.fallback.terminal_win_cmd = "50vsplit new" -    lvim.builtin.which_key.mappings["d"] = {      name = "Debug",      t = { "<cmd>lua require'dap'.toggle_breakpoint()<cr>", "Toggle Breakpoint" }, @@ -51,6 +55,7 @@ M.setup = function()      r = { "<cmd>lua require'dap'.repl.toggle()<cr>", "Toggle Repl" },      s = { "<cmd>lua require'dap'.continue()<cr>", "Start" },      q = { "<cmd>lua require'dap'.close()<cr>", "Quit" }, +    U = { "<cmd>lua require'dapui'.toggle()<cr>", "Toggle UI" },    }    if lvim.builtin.dap.on_config_done then @@ -58,21 +63,65 @@ M.setup = function()    end  end --- TODO put this up there ^^^ call in ftplugin +M.setup_ui = function() +  local status_ok, dap = pcall(require, "dap") +  if not status_ok then +    return +  end +  local dapui = require "dapui" +  dapui.setup { +    expand_lines = true, +    icons = { expanded = "", collapsed = "", circular = "" }, +    mappings = { +      -- Use a table to apply multiple mappings +      expand = { "<CR>", "<2-LeftMouse>" }, +      open = "o", +      remove = "d", +      edit = "e", +      repl = "r", +      toggle = "t", +    }, +    layouts = { +      { +        elements = { +          { id = "scopes", size = 0.33 }, +          { id = "breakpoints", size = 0.17 }, +          { id = "stacks", size = 0.25 }, +          { id = "watches", size = 0.25 }, +        }, +        size = 0.33, +        position = "right", +      }, +      { +        elements = { +          { id = "repl", size = 0.45 }, +          { id = "console", size = 0.55 }, +        }, +        size = 0.27, +        position = "bottom", +      }, +    }, +    floating = { +      max_height = 0.9, +      max_width = 0.5, -- Floats will be treated as percentage of your screen. +      border = vim.g.border_chars, -- Border style. Can be 'single', 'double' or 'rounded' +      mappings = { +        close = { "q", "<Esc>" }, +      }, +    }, +  } --- M.dap = function() ---   if lvim.plugin.dap.active then ---     local dap_install = require "dap-install" ---     dap_install.config("python_dbg", {}) ---   end --- end --- --- M.dap = function() ---   -- gem install readapt ruby-debug-ide ---   if lvim.plugin.dap.active then ---     local dap_install = require "dap-install" ---     dap_install.config("ruby_vsc_dbg", {}) ---   end --- end +  if lvim.builtin.dap.ui.auto_open then +    dap.listeners.after.event_initialized["dapui_config"] = function() +      dapui.open() +    end +    -- dap.listeners.before.event_terminated["dapui_config"] = function() +    --   dapui.close() +    -- end +    -- dap.listeners.before.event_exited["dapui_config"] = function() +    --   dapui.close() +    -- end +  end +end  return M diff --git a/lua/lvim/core/gitsigns.lua b/lua/lvim/core/gitsigns.lua index 0365fc69..cc727c8b 100644 --- a/lua/lvim/core/gitsigns.lua +++ b/lua/lvim/core/gitsigns.lua @@ -8,31 +8,31 @@ M.config = function()        signs = {          add = {            hl = "GitSignsAdd", -          text = "▎", +          text = lvim.icons.ui.BoldLineLeft,            numhl = "GitSignsAddNr",            linehl = "GitSignsAddLn",          },          change = {            hl = "GitSignsChange", -          text = "▎", +          text = lvim.icons.ui.BoldLineLeft,            numhl = "GitSignsChangeNr",            linehl = "GitSignsChangeLn",          },          delete = {            hl = "GitSignsDelete", -          text = "契", +          text = lvim.icons.ui.Triangle,            numhl = "GitSignsDeleteNr",            linehl = "GitSignsDeleteLn",          },          topdelete = {            hl = "GitSignsDelete", -          text = "契", +          text = lvim.icons.ui.Triangle,            numhl = "GitSignsDeleteNr",            linehl = "GitSignsDeleteLn",          },          changedelete = {            hl = "GitSignsChange", -          text = "▎", +          text = lvim.icons.ui.BoldLineLeft,            numhl = "GitSignsChangeNr",            linehl = "GitSignsChangeLn",          }, @@ -79,7 +79,7 @@ M.config = function()  end  M.setup = function() -  local gitsigns = require "gitsigns" +  local gitsigns = reload "gitsigns"    gitsigns.setup(lvim.builtin.gitsigns.opts)    if lvim.builtin.gitsigns.on_config_done then diff --git a/lua/lvim/core/illuminate.lua b/lua/lvim/core/illuminate.lua new file mode 100644 index 00000000..a3ca6711 --- /dev/null +++ b/lua/lvim/core/illuminate.lua @@ -0,0 +1,68 @@ +local M = {} + +M.config = function() +  lvim.builtin.illuminate = { +    active = true, +    on_config_done = nil, +    options = { +      -- providers: provider used to get references in the buffer, ordered by priority +      providers = { +        "lsp", +        "treesitter", +        "regex", +      }, +      -- delay: delay in milliseconds +      delay = 120, +      -- filetypes_denylist: filetypes to not illuminate, this overrides filetypes_allowlist +      filetypes_denylist = { +        "dirvish", +        "fugitive", +        "alpha", +        "NvimTree", +        "packer", +        "neogitstatus", +        "Trouble", +        "lir", +        "Outline", +        "spectre_panel", +        "toggleterm", +        "DressingSelect", +        "TelescopePrompt", +      }, +      -- filetypes_allowlist: filetypes to illuminate, this is overridden by filetypes_denylist +      filetypes_allowlist = {}, +      -- modes_denylist: modes to not illuminate, this overrides modes_allowlist +      modes_denylist = {}, +      -- modes_allowlist: modes to illuminate, this is overridden by modes_denylist +      modes_allowlist = {}, +      -- providers_regex_syntax_denylist: syntax to not illuminate, this overrides providers_regex_syntax_allowlist +      -- Only applies to the 'regex' provider +      -- Use :echom synIDattr(synIDtrans(synID(line('.'), col('.'), 1)), 'name') +      providers_regex_syntax_denylist = {}, +      -- providers_regex_syntax_allowlist: syntax to illuminate, this is overridden by providers_regex_syntax_denylist +      -- Only applies to the 'regex' provider +      -- Use :echom synIDattr(synIDtrans(synID(line('.'), col('.'), 1)), 'name') +      providers_regex_syntax_allowlist = {}, +      -- under_cursor: whether or not to illuminate under the cursor +      under_cursor = true, +    }, +  } +end + +M.setup = function() +  local status_ok, illuminate = pcall(reload, "illuminate") +  if not status_ok then +    return +  end + +  local config_ok, _ = pcall(illuminate.configure, lvim.builtin.illuminate.options) +  if not config_ok then +    return +  end + +  if lvim.builtin.illuminate.on_config_done then +    lvim.builtin.illuminate.on_config_done() +  end +end + +return M diff --git a/lua/lvim/core/indentlines.lua b/lua/lvim/core/indentlines.lua new file mode 100644 index 00000000..dc4a72ba --- /dev/null +++ b/lua/lvim/core/indentlines.lua @@ -0,0 +1,42 @@ +local M = {} + +M.config = function() +  lvim.builtin.indentlines = { +    active = true, +    on_config_done = nil, +    options = { +      enabled = true, +      buftype_exclude = { "terminal", "nofile" }, +      filetype_exclude = { +        "help", +        "startify", +        "dashboard", +        "packer", +        "neogitstatus", +        "NvimTree", +        "Trouble", +        "text", +      }, +      char = lvim.icons.ui.LineLeft, +      show_trailing_blankline_indent = false, +      show_first_indent_level = true, +      use_treesitter = true, +      show_current_context = true, +    }, +  } +end + +M.setup = function() +  local status_ok, indent_blankline = pcall(reload, "indent_blankline") +  if not status_ok then +    return +  end + +  indent_blankline.setup(lvim.builtin.indentlines.options) + +  if lvim.builtin.indentlines.on_config_done then +    lvim.builtin.indentlines.on_config_done() +  end +end + +return M diff --git a/lua/lvim/core/info.lua b/lua/lvim/core/info.lua index da9ddbe6..c413f0f1 100644 --- a/lua/lvim/core/info.lua +++ b/lua/lvim/core/info.lua @@ -25,8 +25,8 @@ local function make_formatters_info(ft)      "Formatters info",      fmt(        "* Active: %s%s", -      table.concat(registered_formatters, "  , "), -      vim.tbl_count(registered_formatters) > 0 and "  " or "" +      table.concat(registered_formatters, " " .. lvim.icons.ui.BoxChecked .. " , "), +      vim.tbl_count(registered_formatters) > 0 and " " .. lvim.icons.ui.BoxChecked .. " " or ""      ),      fmt("* Supported: %s", str_list(supported_formatters)),    } @@ -41,8 +41,8 @@ local function make_code_actions_info(ft)      "Code actions info",      fmt(        "* Active: %s%s", -      table.concat(registered_actions, "  , "), -      vim.tbl_count(registered_actions) > 0 and "  " or "" +      table.concat(registered_actions, " " .. lvim.icons.ui.BoxChecked .. " , "), +      vim.tbl_count(registered_actions) > 0 and " " .. lvim.icons.ui.BoxChecked .. " " or ""      ),    } @@ -57,8 +57,8 @@ local function make_linters_info(ft)      "Linters info",      fmt(        "* Active: %s%s", -      table.concat(registered_linters, "  , "), -      vim.tbl_count(registered_linters) > 0 and "  " or "" +      table.concat(registered_linters, " " .. lvim.icons.ui.BoxChecked .. " , "), +      vim.tbl_count(registered_linters) > 0 and " " .. lvim.icons.ui.BoxChecked .. " " or ""      ),      fmt("* Supported: %s", str_list(supported_linters)),    } @@ -202,7 +202,7 @@ function M.toggle_popup(ft)      vim.fn.matchadd("LvimInfoIdentifier", " " .. ft .. "$")      vim.fn.matchadd("string", "true")      vim.fn.matchadd("string", "active") -    vim.fn.matchadd("string", "") +    vim.fn.matchadd("string", lvim.icons.ui.BoxChecked)      vim.fn.matchadd("boolean", "inactive")      vim.fn.matchadd("error", "false")      tbl_set_highlight(require("lvim.lsp.null-ls.formatters").list_registered(ft), "LvimInfoIdentifier") diff --git a/lua/lvim/core/lir.lua b/lua/lvim/core/lir.lua new file mode 100644 index 00000000..68445664 --- /dev/null +++ b/lua/lvim/core/lir.lua @@ -0,0 +1,118 @@ +local M = {} + +M.config = function() +  lvim.builtin.lir = { +    active = true, +    on_config_done = nil, +    icon = "", +  } + +  local status_ok, _ = pcall(require, "lir") +  if not status_ok then +    return +  end + +  local actions = require "lir.actions" +  local mark_actions = require "lir.mark.actions" +  local clipboard_actions = require "lir.clipboard.actions" + +  lvim.builtin.lir = vim.tbl_extend("force", lvim.builtin.lir, { +    show_hidden_files = false, +    devicons_enable = true, +    mappings = { +      ["l"] = actions.edit, +      ["<CR>"] = actions.edit, +      ["<C-s>"] = actions.split, +      ["v"] = actions.vsplit, +      ["<C-t>"] = actions.tabedit, + +      ["h"] = actions.up, +      ["q"] = actions.quit, + +      ["A"] = actions.mkdir, +      ["a"] = actions.newfile, +      ["r"] = actions.rename, +      ["@"] = actions.cd, +      ["Y"] = actions.yank_path, +      ["i"] = actions.toggle_show_hidden, +      ["d"] = actions.delete, + +      ["J"] = function() +        mark_actions.toggle_mark() +        vim.cmd "normal! j" +      end, +      ["c"] = clipboard_actions.copy, +      ["x"] = clipboard_actions.cut, +      ["p"] = clipboard_actions.paste, +    }, +    float = { +      winblend = 0, +      curdir_window = { +        enable = false, +        highlight_dirname = true, +      }, + +      -- -- You can define a function that returns a table to be passed as the third +      -- -- argument of nvim_open_win(). +      win_opts = function() +        local width = math.floor(vim.o.columns * 0.7) +        local height = math.floor(vim.o.lines * 0.7) +        return { +          border = "rounded", +          width = width, +          height = height, +          -- row = 1, +          -- col = math.floor((vim.o.columns - width) / 2), +        } +      end, +    }, +    hide_cursor = false, +    on_init = function() +      -- use visual mode +      vim.api.nvim_buf_set_keymap( +        0, +        "x", +        "J", +        ':<C-u>lua require"lir.mark.actions".toggle_mark("v")<CR>', +        { noremap = true, silent = true } +      ) + +      -- echo cwd +      -- vim.api.nvim_echo({ { vim.fn.expand "%:p", "Normal" } }, false, {}) +    end, +  }) +end + +function M.icon_setup() +  local function get_hl_by_name(name) +    local ret = vim.api.nvim_get_hl_by_name(name.group, true) +    return string.format("#%06x", ret[name.property]) +  end + +  local found, icon_hl = pcall(get_hl_by_name, { group = "NvimTreeFolderIcon", property = "foreground" }) +  if not found then +    icon_hl = "#42A5F5" +  end + +  reload("nvim-web-devicons").set_icon { +    lir_folder_icon = { +      icon = lvim.builtin.lir.icon, +      color = icon_hl, +      name = "LirFolderNode", +    }, +  } +end + +function M.setup() +  local status_ok, lir = pcall(reload, "lir") +  if not status_ok then +    return +  end +  lir.setup(lvim.builtin.lir) + +  if lvim.builtin.lir.on_config_done then +    lvim.builtin.lir.on_config_done(lir) +  end +end + +return M diff --git a/lua/lvim/core/log.lua b/lua/lvim/core/log.lua index 48891139..d88a659b 100644 --- a/lua/lvim/core/log.lua +++ b/lua/lvim/core/log.lua @@ -12,26 +12,23 @@ vim.tbl_add_reverse_lookup(Log.levels)  local notify_opts = {}  function Log:set_level(level) -  local logger_ok, _ = xpcall(function() -    local log_level = Log.levels[level:upper()] -    local structlog = require "structlog" -    if structlog then -      local logger = structlog.get_logger "lvim" -      for _, s in ipairs(logger.sinks) do -        s.level = log_level -      end +  local logger_ok, logger = pcall(function() +    return require("structlog").get_logger "lvim" +  end) +  local log_level = Log.levels[level:upper()] +  if logger_ok and logger and log_level then +    for _, s in ipairs(logger.sinks) do +      s.level = log_level      end -  end, debug.traceback) -  if not logger_ok then -    Log:debug("Unable to set logger's level: " .. debug.traceback()) +  else +    vim.notify_once("Unable to set logger's level to " .. level)    end    local packer_ok, _ = xpcall(function() -    package.loaded["packer.log"] = nil -    require("packer.log").new { level = lvim.log.level } +    require("packer.log").cfg { log = { level = level } }    end, debug.traceback)    if not packer_ok then -    Log:debug("Unable to set packer's log level: " .. debug.traceback()) +    vim.notify_once("Unable to set packer's log level to " .. level)    end  end @@ -91,7 +88,7 @@ function Log:init()          vim_log_level = vim_log_level + 1        end -      logger:log(vim_log_level, msg) +      self:info(vim_log_level, msg)      end    end @@ -145,8 +142,9 @@ function Log:configure_notifications(notif_handle)  end  --- Adds a log entry using Plenary.log +---@param level integer [same as vim.log.levels]  ---@param msg any ----@param level string [same as vim.log.log_levels] +---@param event any  function Log:add_entry(level, msg, event)    local logger = self:get_logger()    if not logger then @@ -158,11 +156,15 @@ end  ---Retrieves the handle of the logger object  ---@return table|nil logger handle if found  function Log:get_logger() -  if self.__handle then -    return self.__handle +  local logger_ok, logger = pcall(function() +    return require("structlog").get_logger "lvim" +  end) +  if logger_ok and logger then +    return logger    end -  local logger = self:init() +  logger = self:init() +    if not logger then      return    end diff --git a/lua/lvim/core/lualine/components.lua b/lua/lvim/core/lualine/components.lua index c88bf82b..e4148e20 100644 --- a/lua/lvim/core/lualine/components.lua +++ b/lua/lvim/core/lualine/components.lua @@ -12,10 +12,35 @@ local function diff_source()    end  end +local statusline_hl = vim.api.nvim_get_hl_by_name("StatusLine", true) +local cursorline_hl = vim.api.nvim_get_hl_by_name("CursorLine", true) +local normal_hl = vim.api.nvim_get_hl_by_name("Normal", true) + +vim.api.nvim_set_hl(0, "SLCopilot", { fg = "#6CC644", bg = statusline_hl.background }) +vim.api.nvim_set_hl(0, "SLGitIcon", { fg = "#E8AB53", bg = cursorline_hl.background }) +vim.api.nvim_set_hl(0, "SLBranchName", { fg = normal_hl.foreground, bg = cursorline_hl.background }) +vim.api.nvim_set_hl(0, "SLProgress", { fg = "#ECBE7B", bg = statusline_hl.background }) + +local location_color = nil +local branch = lvim.icons.git.Branch +local separator = lvim.icons.ui.LineMiddle + +if lvim.colorscheme == "tokyonight" then +  location_color = "SLBranchName" +  branch = "%#SLGitIcon#" .. lvim.icons.git.Branch .. "%*" .. "%#SLBranchName#" + +  local status_ok, tnc = pcall(require, "tokyonight.colors") +  if status_ok then +    local tncolors = tnc.setup { transform = true } +    vim.api.nvim_set_hl(0, "SLSeparator", { fg = cursorline_hl.background, bg = tncolors.black }) +    separator = "%#SLSeparator#" .. lvim.icons.ui.LineMiddle .. "%*" +  end +end +  return {    mode = {      function() -      return " " +      return " " .. lvim.icons.ui.Target .. " "      end,      padding = { left = 0, right = 0 },      color = {}, @@ -23,9 +48,8 @@ return {    },    branch = {      "b:gitsigns_head", -    icon = " ", +    icon = branch,      color = { gui = "bold" }, -    cond = conditions.hide_in_width,    },    filename = {      "filename", @@ -35,7 +59,12 @@ return {    diff = {      "diff",      source = diff_source, -    symbols = { added = "  ", modified = " ", removed = " " }, +    symbols = { +      added = lvim.icons.git.LineAdded .. " ", +      modified = lvim.icons.git.LineModified .. " ", +      removed = lvim.icons.git.LineRemoved .. " ", +    }, +    padding = { left = 2, right = 1 },      diff_color = {        added = { fg = colors.green },        modified = { fg = colors.yellow }, @@ -49,7 +78,9 @@ return {        if vim.bo.filetype == "python" then          local venv = os.getenv "CONDA_DEFAULT_ENV" or os.getenv "VIRTUAL_ENV"          if venv then -          return string.format("  (%s)", utils.env_cleanup(venv)) +          local icons = require "nvim-web-devicons" +          local py_icon, _ = icons.get_icon ".py" +          return string.format(" " .. py_icon .. " (%s)", utils.env_cleanup(venv))          end        end        return "" @@ -60,12 +91,17 @@ return {    diagnostics = {      "diagnostics",      sources = { "nvim_diagnostic" }, -    symbols = { error = " ", warn = " ", info = " ", hint = " " }, -    cond = conditions.hide_in_width, +    symbols = { +      error = lvim.icons.diagnostics.BoldError .. " ", +      warn = lvim.icons.diagnostics.BoldWarning .. " ", +      info = lvim.icons.diagnostics.BoldInformation .. " ", +      hint = lvim.icons.diagnostics.BoldHint .. " ", +    }, +    -- cond = conditions.hide_in_width,    },    treesitter = {      function() -      return "" +      return lvim.icons.ui.Tree      end,      color = function()        local buf = vim.api.nvim_get_current_buf() @@ -87,12 +123,17 @@ return {        end        local buf_ft = vim.bo.filetype        local buf_client_names = {} +      local copilot_active = false        -- add client        for _, client in pairs(buf_clients) do -        if client.name ~= "null-ls" then +        if client.name ~= "null-ls" and client.name ~= "copilot" then            table.insert(buf_client_names, client.name)          end + +        if client.name == "copilot" then +          copilot_active = true +        end        end        -- add formatter @@ -106,26 +147,35 @@ return {        vim.list_extend(buf_client_names, supported_linters)        local unique_client_names = vim.fn.uniq(buf_client_names) -      return "[" .. table.concat(unique_client_names, ", ") .. "]" + +      local language_servers = "[" .. table.concat(unique_client_names, ", ") .. "]" + +      if copilot_active then +        language_servers = language_servers .. "%#SLCopilot#" .. " " .. lvim.icons.git.Octoface .. "%*" +      end + +      return language_servers      end, +    separator = separator,      color = { gui = "bold" },      cond = conditions.hide_in_width,    }, -  location = { "location", cond = conditions.hide_in_width, color = {} }, -  progress = { "progress", cond = conditions.hide_in_width, color = {} }, +  location = { "location", color = location_color }, +  progress = { +    "progress", +    fmt = function() +      return "%P/%L" +    end, +    color = {}, +  }, +    spaces = {      function() -      if not vim.api.nvim_buf_get_option(0, "expandtab") then -        return "Tab size: " .. vim.api.nvim_buf_get_option(0, "tabstop") .. " " -      end -      local size = vim.api.nvim_buf_get_option(0, "shiftwidth") -      if size == 0 then -        size = vim.api.nvim_buf_get_option(0, "tabstop") -      end -      return "Spaces: " .. size .. " " +      local shiftwidth = vim.api.nvim_buf_get_option(0, "shiftwidth") +      return lvim.icons.ui.Tab .. " " .. shiftwidth      end, -    cond = conditions.hide_in_width, -    color = {}, +    separator = separator, +    padding = 1,    },    encoding = {      "o:encoding", @@ -133,7 +183,7 @@ return {      color = {},      cond = conditions.hide_in_width,    }, -  filetype = { "filetype", cond = conditions.hide_in_width }, +  filetype = { "filetype", cond = nil, padding = { left = 1, right = 1 } },    scrollbar = {      function()        local current_line = vim.fn.line "." @@ -144,7 +194,7 @@ return {        return chars[index]      end,      padding = { left = 0, right = 0 }, -    color = { fg = colors.yellow, bg = colors.bg }, +    color = "SLProgress",      cond = nil,    },  } diff --git a/lua/lvim/core/lualine/conditions.lua b/lua/lvim/core/lualine/conditions.lua index 6e120b26..42d52a83 100644 --- a/lua/lvim/core/lualine/conditions.lua +++ b/lua/lvim/core/lualine/conditions.lua @@ -1,11 +1,11 @@ -local window_width_limit = 70 +local window_width_limit = 100  local conditions = {    buffer_not_empty = function()      return vim.fn.empty(vim.fn.expand "%:t") ~= 1    end,    hide_in_width = function() -    return vim.fn.winwidth(0) > window_width_limit +    return vim.o.columns > window_width_limit    end,    -- check_git_workspace = function()    --   local filepath = vim.fn.expand "%:p:h" diff --git a/lua/lvim/core/lualine/init.lua b/lua/lvim/core/lualine/init.lua index e041e8a8..0ee35c04 100644 --- a/lua/lvim/core/lualine/init.lua +++ b/lua/lvim/core/lualine/init.lua @@ -9,7 +9,7 @@ M.config = function()        section_separators = nil,        theme = nil,        disabled_filetypes = nil, -      globalstatus = false, +      globalstatus = true,      },      sections = {        lualine_a = nil, @@ -34,16 +34,19 @@ 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 +  local status_ok, lualine = pcall(require, "lualine") +  if not status_ok then +    return +  end +    require("lvim.core.lualine.styles").update() -  local lualine = require "lualine"    lualine.setup(lvim.builtin.lualine)    if lvim.builtin.lualine.on_config_done then diff --git a/lua/lvim/core/lualine/styles.lua b/lua/lvim/core/lualine/styles.lua index 8991d9d9..81dbbabb 100644 --- a/lua/lvim/core/lualine/styles.lua +++ b/lua/lvim/core/lualine/styles.lua @@ -11,6 +11,7 @@ styles.none = {    style = "none",    options = {      theme = "auto", +    globalstatus = true,      icons_enabled = lvim.use_icons,      component_separators = { left = "", right = "" },      section_separators = { left = "", right = "" }, @@ -40,9 +41,16 @@ styles.default = {    style = "default",    options = {      theme = "auto", +    globalstatus = true,      icons_enabled = lvim.use_icons, -    component_separators = { left = "", right = "" }, -    section_separators = { left = "", right = "" }, +    component_separators = { +      left = lvim.icons.ui.DividerRight, +      right = lvim.icons.ui.DividerLeft, +    }, +    section_separators = { +      left = lvim.icons.ui.BoldDividerRight, +      right = lvim.icons.ui.BoldDividerLeft, +    },      disabled_filetypes = {},    },    sections = { @@ -69,10 +77,11 @@ styles.lvim = {    style = "lvim",    options = {      theme = "auto", +    globalstatus = true,      icons_enabled = lvim.use_icons,      component_separators = { left = "", right = "" },      section_separators = { left = "", right = "" }, -    disabled_filetypes = { "alpha", "NvimTree", "Outline" }, +    disabled_filetypes = { "alpha" },    },    sections = {      lualine_a = { @@ -80,7 +89,6 @@ styles.lvim = {      },      lualine_b = {        components.branch, -      components.filename,      },      lualine_c = {        components.diff, @@ -88,27 +96,39 @@ styles.lvim = {      },      lualine_x = {        components.diagnostics, -      components.treesitter,        components.lsp, +      components.spaces,        components.filetype,      }, -    lualine_y = {}, +    lualine_y = { components.location },      lualine_z = { -      components.scrollbar, +      components.progress,      },    },    inactive_sections = {      lualine_a = { -      "filename", +      components.mode, +    }, +    lualine_b = { +      components.branch, +    }, +    lualine_c = { +      components.diff, +      components.python_env, +    }, +    lualine_x = { +      components.diagnostics, +      components.lsp, +      components.spaces, +      components.filetype, +    }, +    lualine_y = { components.location }, +    lualine_z = { +      components.progress,      }, -    lualine_b = {}, -    lualine_c = {}, -    lualine_x = {}, -    lualine_y = {}, -    lualine_z = {},    },    tabline = {}, -  extensions = { "nvim-tree" }, +  extensions = {},  }  function M.get_style(style) @@ -132,6 +152,14 @@ function M.update()    local style = M.get_style(lvim.builtin.lualine.style)    lvim.builtin.lualine = vim.tbl_deep_extend("keep", lvim.builtin.lualine, style) + +  local color_template = vim.g.colors_name or lvim.colorscheme +  local theme_supported, template = pcall(function() +    require("lualine.utils.loader").load_theme(color_template) +  end) +  if theme_supported and template then +    lvim.builtin.lualine.options.theme = color_template +  end  end  return M diff --git a/lua/lvim/core/mason.lua b/lua/lvim/core/mason.lua index 39be4f42..19dee633 100644 --- a/lua/lvim/core/mason.lua +++ b/lua/lvim/core/mason.lua @@ -3,6 +3,7 @@ local M = {}  function M.config()    lvim.builtin.mason = {      ui = { +      border = "rounded",        keymaps = {          toggle_package_expand = "<CR>",          install_package = "i", @@ -30,7 +31,7 @@ function M.config()  end  function M.setup() -  local status_ok, mason = pcall(require, "mason") +  local status_ok, mason = pcall(reload, "mason")    if not status_ok then      return    end diff --git a/lua/lvim/core/notify.lua b/lua/lvim/core/notify.lua index 2db4c4d5..b08c45a6 100644 --- a/lua/lvim/core/notify.lua +++ b/lua/lvim/core/notify.lua @@ -3,7 +3,7 @@ local M = {}  local Log = require "lvim.core.log"  local defaults = { -  active = false, +  active = true,    on_config_done = nil,    opts = {      ---@usage Animation style one of { "fade", "slide", "fade_in_slide_out", "static" } @@ -29,11 +29,11 @@ local defaults = {      ---@usage Icons for the different levels      icons = { -      ERROR = "", -      WARN = "", -      INFO = "", -      DEBUG = "", -      TRACE = "✎", +      ERROR = lvim.icons.diagnostics.Error, +      WARN = lvim.icons.diagnostics.Warning, +      INFO = lvim.icons.diagnostics.Information, +      DEBUG = lvim.icons.diagnostics.Debug, +      TRACE = lvim.icons.diagnostics.Trace,      },    },  } @@ -43,7 +43,7 @@ function M.config()      defaults.opts.icons = {        ERROR = "[ERROR]",        WARN = "[WARNING]", -      INFO = "[INFo]", +      INFO = "[INFO]",        DEBUG = "[DEBUG]",        TRACE = "[TRACE]",      } @@ -58,7 +58,11 @@ function M.setup()    end    local opts = lvim.builtin.notify and lvim.builtin.notify.opts or defaults -  local notify = require "notify" + +  local status_ok, notify = pcall(require, "notify") +  if not status_ok then +    return +  end    notify.setup(opts)    vim.notify = notify diff --git a/lua/lvim/core/nvimtree.lua b/lua/lvim/core/nvimtree.lua index 15e80e85..199279a6 100644 --- a/lua/lvim/core/nvimtree.lua +++ b/lua/lvim/core/nvimtree.lua @@ -6,34 +6,24 @@ function M.config()      active = true,      on_config_done = nil,      setup = { -      disable_netrw = true, -      hijack_netrw = true, -      open_on_setup = false, -      open_on_setup_file = false, -      sort_by = "name", -      ignore_buffer_on_setup = false,        ignore_ft_on_setup = {          "startify",          "dashboard",          "alpha",        }, -      auto_reload_on_write = true, -      hijack_unnamed_buffer_when_opening = false, +      auto_reload_on_write = false,        hijack_directories = { -        enable = true, -        auto_open = true, +        enable = false,        }, -      open_on_tab = false, -      hijack_cursor = false, -      update_cwd = false, +      update_cwd = true,        diagnostics = {          enable = lvim.use_icons,          show_on_dirs = false,          icons = { -          hint = "", -          info = "", -          warning = "", -          error = "", +          hint = lvim.icons.diagnostics.BoldHint, +          info = lvim.icons.diagnostics.BoldInformation, +          warning = lvim.icons.diagnostics.BoldWarning, +          error = lvim.icons.diagnostics.BoldError,          },        },        update_focused_file = { @@ -52,10 +42,8 @@ function M.config()        },        view = {          width = 30, -        height = 30,          hide_root_folder = false,          side = "left", -        preserve_window_proportions = false,          mappings = {            custom_only = false,            list = {}, @@ -83,27 +71,28 @@ function M.config()              folder_arrow = lvim.use_icons,            },            glyphs = { -            default = "", -            symlink = "", +            default = lvim.icons.ui.Text, +            symlink = lvim.icons.ui.FileSymlink,              git = { -              unstaged = "", -              staged = "S", -              unmerged = "", -              renamed = "➜", -              deleted = "", -              untracked = "U", -              ignored = "◌", +              deleted = lvim.icons.git.FileDeleted, +              ignored = lvim.icons.git.FileIgnored, +              renamed = lvim.icons.git.FileRenamed, +              staged = lvim.icons.git.FileStaged, +              unmerged = lvim.icons.git.FileUnmerged, +              unstaged = lvim.icons.git.FileUnstaged, +              untracked = lvim.icons.git.FileUntracked,              },              folder = { -              default = "", -              open = "", -              empty = "", -              empty_open = "", -              symlink = "", +              default = lvim.icons.ui.Folder, +              empty = lvim.icons.ui.EmptyFolder, +              empty_open = lvim.icons.ui.EmptyFolderOpen, +              open = lvim.icons.ui.FolderOpen, +              symlink = lvim.icons.ui.FolderSymlink,              },            },          },          highlight_git = true, +        group_empty = false,          root_folder_modifier = ":t",        },        filters = { @@ -158,6 +147,24 @@ function M.setup()      return    end +  local status_ok_1, utils = pcall(require, "nvim-tree.utils") +  if not status_ok_1 then +    return +  end + +  local function notify_level() +    return function(msg) +      vim.schedule(function() +        vim.api.nvim_echo({ { msg, "WarningMsg" } }, false, {}) +      end) +    end +  end + +  utils.notify.warn = notify_level(vim.log.levels.WARN) +  utils.notify.error = notify_level(vim.log.levels.ERROR) +  utils.notify.info = notify_level(vim.log.levels.INFO) +  utils.notify.debug = notify_level(vim.log.levels.DEBUG) +    if lvim.builtin.nvimtree._setup_called then      Log:debug "ignoring repeated setup call for nvim-tree, see kyazdani42/nvim-tree.lua#1308"      return diff --git a/lua/lvim/core/project.lua b/lua/lvim/core/project.lua index e33d8720..c3734a16 100644 --- a/lua/lvim/core/project.lua +++ b/lua/lvim/core/project.lua @@ -22,7 +22,7 @@ function M.config()      detection_methods = { "pattern" },      ---@usage patterns used to detect root dir, when **"pattern"** is in detection_methods -    patterns = { ".git", "_darcs", ".hg", ".bzr", ".svn", "Makefile", "package.json" }, +    patterns = { ".git", "_darcs", ".hg", ".bzr", ".svn", "Makefile", "package.json", "pom.xml" },      ---@ Show hidden files in telescope when searching for files in a project      show_hidden = false, diff --git a/lua/lvim/core/telescope.lua b/lua/lvim/core/telescope.lua index f556913b..77bf552d 100644 --- a/lua/lvim/core/telescope.lua +++ b/lua/lvim/core/telescope.lua @@ -1,5 +1,63 @@  local M = {} +local function get_pickers(actions) +  return { +    find_files = { +      theme = "dropdown", +      hidden = true, +      previewer = false, +    }, +    live_grep = { +      --@usage don't include the filename in the search results +      only_sort_text = true, +      theme = "dropdown", +    }, +    grep_string = { +      only_sort_text = true, +      theme = "dropdown", +    }, +    buffers = { +      theme = "dropdown", +      previewer = false, +      initial_mode = "normal", +      mappings = { +        i = { +          ["<C-d>"] = actions.delete_buffer, +        }, +        n = { +          ["dd"] = actions.delete_buffer, +        }, +      }, +    }, +    planets = { +      show_pluto = true, +      show_moon = true, +    }, +    git_files = { +      theme = "dropdown", +      hidden = true, +      previewer = false, +      show_untracked = true, +    }, +    lsp_references = { +      theme = "dropdown", +      initial_mode = "normal", +    }, +    lsp_definitions = { +      theme = "dropdown", +      initial_mode = "normal", +    }, +    lsp_declarations = { +      theme = "dropdown", +      initial_mode = "normal", +    }, +    lsp_implementations = { +      theme = "dropdown", +      initial_mode = "normal", +    }, +  } +end +  function M.config()    -- Define this minimal config so that it's available if telescope is not yet available. @@ -15,8 +73,8 @@ function M.config()    end    lvim.builtin.telescope = vim.tbl_extend("force", lvim.builtin.telescope, {      defaults = { -      prompt_prefix = " ", -      selection_caret = " ", +      prompt_prefix = lvim.icons.ui.Telescope .. " ", +      selection_caret = lvim.icons.ui.Forward .. " ",        entry_prefix = "  ",        initial_mode = "insert",        selection_strategy = "reset", @@ -47,6 +105,7 @@ function M.config()          "--hidden",          "--glob=!.git/",        }, +      ---@usage Mappings are fully customizable. Many familiar mapping patterns are setup as defaults.        mappings = {          i = {            ["<C-n>"] = actions.move_selection_next, @@ -63,23 +122,16 @@ function M.config()            ["<C-q>"] = actions.smart_send_to_qflist + actions.open_qflist,          },        }, +      pickers = get_pickers(actions),        file_ignore_patterns = {}, -      path_display = { shorten = 5 }, +      path_display = { "smart" },        winblend = 0,        border = {},        borderchars = { "─", "│", "─", "│", "╭", "╮", "╯", "╰" },        color_devicons = true,        set_env = { ["COLORTERM"] = "truecolor" }, -- default = nil,      }, -    pickers = { -      find_files = { -        hidden = true, -      }, -      live_grep = { -        --@usage don't include the filename in the search results -        only_sort_text = true, -      }, -    }, +    pickers = get_pickers(actions),      extensions = {        fzf = {          fuzzy = true, -- false will only do exact matching @@ -94,7 +146,6 @@ end  function M.setup()    local previewers = require "telescope.previewers"    local sorters = require "telescope.sorters" -  local actions = require "telescope.actions"    lvim.builtin.telescope = vim.tbl_extend("keep", {      file_previewer = previewers.vim_buffer_cat.new, @@ -102,23 +153,6 @@ function M.setup()      qflist_previewer = previewers.vim_buffer_qflist.new,      file_sorter = sorters.get_fuzzy_file,      generic_sorter = sorters.get_generic_fuzzy_sorter, -    ---@usage Mappings are fully customizable. Many familiar mapping patterns are setup as defaults. -    mappings = { -      i = { -        ["<C-n>"] = actions.move_selection_next, -        ["<C-p>"] = actions.move_selection_previous, -        ["<C-c>"] = actions.close, -        ["<C-j>"] = actions.cycle_history_next, -        ["<C-k>"] = actions.cycle_history_prev, -        ["<C-q>"] = actions.smart_send_to_qflist + actions.open_qflist, -        ["<CR>"] = actions.select_default + actions.center, -      }, -      n = { -        ["<C-n>"] = actions.move_selection_next, -        ["<C-p>"] = actions.move_selection_previous, -        ["<C-q>"] = actions.smart_send_to_qflist + actions.open_qflist, -      }, -    },    }, lvim.builtin.telescope)    local telescope = require "telescope" diff --git a/lua/lvim/core/telescope/custom-finders.lua b/lua/lvim/core/telescope/custom-finders.lua index 69428a44..9ab06326 100644 --- a/lua/lvim/core/telescope/custom-finders.lua +++ b/lua/lvim/core/telescope/custom-finders.lua @@ -88,11 +88,12 @@ end  -- Smartly opens either git_files or find_files, depending on whether the working directory is  -- contained in a Git repo. -function M.find_project_files() -  local ok = pcall(builtin.git_files) +function M.find_project_files(opts) +  opts = opts or {} +  local ok = pcall(builtin.git_files, opts)    if not ok then -    builtin.find_files() +    builtin.find_files(opts)    end  end diff --git a/lua/lvim/core/terminal.lua b/lua/lvim/core/terminal.lua index 6f543d06..006452e1 100644 --- a/lua/lvim/core/terminal.lua +++ b/lua/lvim/core/terminal.lua @@ -3,11 +3,11 @@ local Log = require "lvim.core.log"  M.config = function()    lvim.builtin["terminal"] = { +    active = true,      on_config_done = nil,      -- size can be a number or function which is passed the current terminal      size = 20, -    -- open_mapping = [[<c-\>]], -    open_mapping = [[<c-t>]], +    open_mapping = [[<c-\>]],      hide_numbers = true, -- hide the number column in toggleterm buffers      shade_filetypes = {},      shade_terminals = true, @@ -39,8 +39,11 @@ M.config = function()      -- { exec, keymap, name}      -- lvim.builtin.terminal.execs = {{}} to overwrite      -- lvim.builtin.terminal.execs[#lvim.builtin.terminal.execs+1] = {"gdb", "tg", "GNU Debugger"} +    -- TODO: pls add mappings in which key and refactor this      execs = { -      { "lazygit", "<leader>gg", "LazyGit", "float" }, +      { vim.o.shell, "<M-1>", "Horizontal Terminal", "horizontal", 10 }, +      { vim.o.shell, "<M-2>", "Vertical Terminal", "vertical", 60 }, +      { vim.o.shell, "<M-3>", "Float Terminal", "float", nil },      },    }  end @@ -57,7 +60,7 @@ M.setup = function()        -- NOTE: unable to consistently bind id/count <= 9, see #2146        count = i + 100,        direction = exec[4] or lvim.builtin.terminal.direction, -      size = lvim.builtin.terminal.size, +      size = exec[5] or lvim.builtin.terminal.size,      }      M.add_exec(opts) @@ -76,14 +79,14 @@ M.add_exec = function(opts)    end    vim.keymap.set({ "n", "t" }, opts.keymap, function() -    M._exec_toggle { cmd = opts.cmd, count = opts.count, direction = opts.direction } +    M._exec_toggle { cmd = opts.cmd, count = opts.count, direction = opts.direction, size = opts.size }    end, { desc = opts.label, noremap = true, silent = true })  end  M._exec_toggle = function(opts)    local Terminal = require("toggleterm.terminal").Terminal    local term = Terminal:new { cmd = opts.cmd, count = opts.count, direction = opts.direction } -  term:toggle(lvim.builtin.terminal.size, opts.direction) +  term:toggle(opts.size, opts.direction)  end  ---Toggles a log viewer according to log.viewer.layout_config @@ -109,4 +112,24 @@ M.toggle_log_view = function(logfile)    log_view:toggle()  end +M.lazygit_toggle = function() +  local Terminal = require("toggleterm.terminal").Terminal +  local lazygit = Terminal:new { +    cmd = "lazygit", +    hidden = true, +    direction = "float", +    float_opts = { +      border = "none", +      width = 100000, +      height = 100000, +    }, +    on_open = function(_) +      vim.cmd "startinsert!" +    end, +    on_close = function(_) end, +    count = 99, +  } +  lazygit:toggle() +end +  return M diff --git a/lua/lvim/core/theme.lua b/lua/lvim/core/theme.lua new file mode 100644 index 00000000..0f960d3d --- /dev/null +++ b/lua/lvim/core/theme.lua @@ -0,0 +1,113 @@ +local Log = require "lvim.core.log" + +local M = {} + +M.config = function() +  lvim.builtin.theme = { +    name = "tokyonight", +    options = { +      on_highlights = function(hl, c) +        hl.IndentBlanklineContextChar = { +          fg = c.dark5, +        } +        hl.TSConstructor = { +          fg = c.blue1, +        } +        hl.TSTagDelimiter = { +          fg = c.dark5, +        } +        -- local prompt = "#2d3149" +        -- hl.TelescopeNormal = { +        --   bg = c.bg_dark, +        --   fg = c.fg_dark, +        -- } +        -- hl.TelescopeBorder = { +        --   bg = c.bg_dark, +        --   fg = c.bg_dark, +        -- } +        -- hl.TelescopePromptNormal = { +        --   bg = prompt, +        -- } +        -- hl.TelescopePromptBorder = { +        --   bg = prompt, +        --   fg = prompt, +        -- } +        -- hl.TelescopePromptTitle = { +        --   bg = prompt, +        --   fg = prompt, +        -- } +        -- hl.TelescopePreviewTitle = { +        --   bg = c.bg_dark, +        --   fg = c.bg_dark, +        -- } +        -- hl.TelescopeResultsTitle = { +        --   bg = c.bg_dark, +        --   fg = c.bg_dark, +        -- } +      end, +      style = "night", -- The theme comes in three styles, `storm`, a darker variant `night` and `day` +      transparent = lvim.transparent_window, -- Enable this to disable setting the background color +      terminal_colors = true, -- Configure the colors used when opening a `:terminal` in Neovim +      styles = { +        -- Style to be applied to different syntax groups +        -- Value is any valid attr-list value for `:help nvim_set_hl` +        comments = { italic = true }, +        keywords = { italic = true }, +        functions = {}, +        variables = {}, +        -- Background styles. Can be "dark", "transparent" or "normal" +        sidebars = "dark", -- style for sidebars, see below +        floats = "dark", -- style for floating windows +      }, +      -- Set a darker background on sidebar-like windows. For example: `["qf", "vista_kind", "terminal", "packer"]` +      sidebars = { +        "qf", +        "vista_kind", +        "terminal", +        "packer", +        "spectre_panel", +        "NeogitStatus", +        "help", +      }, +      day_brightness = 0.3, -- Adjusts the brightness of the colors of the **Day** style. Number between 0 and 1, from dull to vibrant colors +      hide_inactive_statusline = false, -- Enabling this option, will hide inactive statuslines and replace them with a thin border instead. Should work with the standard **StatusLine** and **LuaLine**. +      dim_inactive = false, -- dims inactive windows +      lualine_bold = false, -- When `true`, section headers in the lualine theme will be bold +      use_background = true, -- can be light/dark/auto. When auto, background will be set to vim.o.background +    }, +  } +  local status_ok, theme = pcall(require, "tokyonight") +  if not status_ok then +    return +  end + +  theme.setup(lvim.builtin.theme.options) +end + +M.setup = function() +  -- avoid running in headless mode since it's harder to detect failures +  if #vim.api.nvim_list_uis() == 0 then +    Log:debug "headless mode detected, skipping running setup for lualine" +    return +  end + +  local status_ok, theme = pcall(require, "tokyonight") +  if status_ok and theme then +    theme.setup(lvim.builtin.theme.options) +  end + +  -- ref: https://github.com/neovim/neovim/issues/18201#issuecomment-1104754564 +  local colors = vim.api.nvim_get_runtime_file(("colors/%s.*"):format(lvim.colorscheme), false) +  if #colors == 0 then +    Log:warn(string.format("Could not find '%s' colorscheme", lvim.colorscheme)) +    lvim.colorscheme = "tokyonight" +  end + +  vim.g.colors_name = lvim.colorscheme +  vim.cmd("colorscheme " .. lvim.colorscheme) + +  require("lvim.core.lualine").setup() +  require("lvim.core.lir").icon_setup() +end + +return M diff --git a/lua/lvim/core/which-key.lua b/lua/lvim/core/which-key.lua index 2301943f..55e3aae0 100644 --- a/lua/lvim/core/which-key.lua +++ b/lua/lvim/core/which-key.lua @@ -6,8 +6,8 @@ M.config = function()      on_config_done = nil,      setup = {        plugins = { -        marks = true, -- shows a list of your marks on ' and ` -        registers = true, -- shows your registers on " in NORMAL or <C-r> in INSERT mode +        marks = false, -- shows a list of your marks on ' and ` +        registers = false, -- shows your registers on " in NORMAL or <C-r> in INSERT mode          -- the presets plugin, adds help for a bunch of default keybindings in Neovim          -- No actual key bindings are created          presets = { @@ -15,16 +15,16 @@ M.config = function()            motions = false, -- adds help for motions            text_objects = false, -- help for text objects triggered after entering an operator            windows = false, -- default bindings on <c-w> -          nav = true, -- misc bindings to work with windows -          z = true, -- bindings for folds, spelling and others prefixed with z -          g = true, -- bindings for prefixed with g +          nav = false, -- misc bindings to work with windows +          z = false, -- bindings for folds, spelling and others prefixed with z +          g = false, -- bindings for prefixed with g          },          spelling = { enabled = true, suggestions = 20 }, -- use which-key for spelling hints        },        icons = { -        breadcrumb = "»", -- symbol used in the command line area that shows your active key combo -        separator = "➜", -- symbol used between a key and it's label -        group = "+", -- symbol prepended to a group +        breadcrumb = lvim.icons.ui.DoubleChevronRight, -- symbol used in the command line area that shows your active key combo +        separator = lvim.icons.ui.BoldArrowRight, -- symbol used between a key and it's label +        group = lvim.icons.ui.Plus, -- symbol prepended to a group        },        popup_mappings = {          scroll_down = "<c-d>", -- binding to scroll down inside the popup @@ -130,8 +130,9 @@ M.config = function()        -- " Debugging        g = {          name = "Git", -        j = { "<cmd>lua require 'gitsigns'.next_hunk()<cr>", "Next Hunk" }, -        k = { "<cmd>lua require 'gitsigns'.prev_hunk()<cr>", "Prev Hunk" }, +        g = { "<cmd>lua require 'lvim.core.terminal'.lazygit_toggle()<cr>", "Lazygit" }, +        j = { "<cmd>lua require 'gitsigns'.next_hunk({navigation_message = false})<cr>", "Next Hunk" }, +        k = { "<cmd>lua require 'gitsigns'.prev_hunk({navigation_message = false})<cr>", "Prev Hunk" },          l = { "<cmd>lua require 'gitsigns'.blame_line()<cr>", "Blame" },          p = { "<cmd>lua require 'gitsigns'.preview_hunk()<cr>", "Preview Hunk" },          r = { "<cmd>lua require 'gitsigns'.reset_hunk()<cr>", "Reset Hunk" }, @@ -170,12 +171,6 @@ M.config = function()            "Prev Diagnostic",          },          l = { vim.lsp.codelens.run, "CodeLens Action" }, -        p = { -          name = "Peek", -          d = { "<cmd>lua require('lvim.lsp.peek').Peek('definition')<cr>", "Definition" }, -          t = { "<cmd>lua require('lvim.lsp.peek').Peek('typeDefinition')<cr>", "Type Definition" }, -          i = { "<cmd>lua require('lvim.lsp.peek').Peek('implementation')<cr>", "Implementation" }, -        },          q = { vim.diagnostic.setloclist, "Quickfix" },          r = { vim.lsp.buf.rename, "Rename" },          s = { "<cmd>Telescope lsp_document_symbols<cr>", "Document Symbols" }, | 
