From 04b057a757511d0aa2c86605821e59bfe3e748be Mon Sep 17 00:00:00 2001 From: rootiest Date: Sun, 15 Sep 2024 07:33:17 -0400 Subject: [PATCH] feat: add additional configuration options to dashboard settings --- logo/neovim.txt | 15 +++ lua/config/options.lua | 23 +++- lua/data/dash.lua | 131 ++++++++--------------- lua/plugins/cmp.lua | 4 +- lua/plugins/dashboard/alpha.lua | 8 +- lua/plugins/dashboard/nvim-dashboard.lua | 9 +- lua/utils/highlight.lua | 9 -- 7 files changed, 95 insertions(+), 104 deletions(-) create mode 100644 logo/neovim.txt diff --git a/logo/neovim.txt b/logo/neovim.txt new file mode 100644 index 0000000..111274e --- /dev/null +++ b/logo/neovim.txt @@ -0,0 +1,15 @@ + ███ ███ + ████ ████ +  ████ █████ + █ ████ █████ + ██ ████ █████ + ███ ████ █████ + ████ ████ ████ + █████ ████████ + █████ ███████ + █████ ██████ + █████ █████ + ████ ████ + ███ ███ + + N E O V I M diff --git a/lua/config/options.lua b/lua/config/options.lua index 5d51c38..a39fc17 100644 --- a/lua/config/options.lua +++ b/lua/config/options.lua @@ -78,6 +78,21 @@ vim.g.tabline = "bufferline" ---@type string Options: [tabline] -- │ │ -- ╰───────────────────────────╯ +-- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ DASHBOARD ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +vim.g.dashboard = "alpha" ---@type string Options: [dashboard] +-- ╭───────────────────────────╮  alpha +-- │ │  nvim-dashboard +-- │ Dashboards: │  none +-- │ Choose a plugin from │ +-- │ the list  │ +-- │ │ +-- ╰───────────────────────────╯ + +-- Dashboard logo file +vim.g.dash_logo = "logo/neovim.txt" ---@type string Options: [dash logo] +-- Dashboard header color +vim.g.DashboardHeaderColor = "#88fc9a"---@type string Options: [hex color] + -- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ STATUS LINE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ vim.g.statusline = "lualine" ---@type string Options: [statusline] -- ╭───────────────────────────╮  lualine @@ -87,7 +102,7 @@ vim.g.statusline = "lualine" ---@type string Options: [statusline] -- │ the list  │  none -- │ │ -- ╰───────────────────────────╯ --- + -- Click git components on statusline to open LazyGit vim.g.statusline_clickable_git = false ---@type boolean Options: -- Show wakatime stats on statusline @@ -107,14 +122,14 @@ vim.g.stats_ignored_players = { ---@type string[] Options: [ignored playe -- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ COLOR ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -- Background color vim.o.background = "dark" ---@type string Options: --- Dashboard header color -vim.g.DashboardHeaderColor = "#88fc9a"---@type string Options: [hex color] -- Disable Transparency vim.g.disable_transparency = true ---@type boolean Options: +-- Set colorcolumn +vim.opt.colorcolumn = "120" ---@type string|table Options: [column] -- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Completion ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -- Cmp Window Border -vim.g.completion_round_borders_enabled = true ---@type boolean Options: +vim.g.completion_borders = "rounded" ---@type string Options: [round|sharp|flat] -- stylua: ignore end diff --git a/lua/data/dash.lua b/lua/data/dash.lua index 49c8a10..3d4d554 100644 --- a/lua/data/dash.lua +++ b/lua/data/dash.lua @@ -6,29 +6,35 @@ local M = {} ---- Function to setup the Alpha dashboard options ----@return table The alpha dashboard options +-- Define default path to the logo art +M.logo = vim.g.dash_logo or "logo/neovim.txt" + +--- Alpha plugin configuration M.alpha = { + --- Function to setup the Alpha dashboard options + ---@return table dashboard The alpha dashboard options opts = function() + -- Load the alpha plugin dashboard-nvim theme local dashboard = require("alpha.themes.dashboard") - local header = { - [[ ███ ███ ]], - [[ ████ ████ ]], - [[  ████ █████ ]], - [[ █ ████ █████ ]], - [[ ██ ████ █████ ]], - [[ ███ ████ █████ ]], - [[ ████ ████ ████ ]], - [[ █████ ████████ ]], - [[ █████ ███████ ]], - [[ █████ ██████ ]], - [[ █████ █████ ]], - [[ ████ ████ ]], - [[ ███ ███ ]], - [[ ]], - [[ N E O V I M ]], - } - dashboard.section.header.val = header + + --- Function to read the ASCII art from the logo file + ---@param logo_path string The path to the logo file + ---@return table art The ASCII art lines + local function read_ascii_art(logo_path) + local lines = {} + for line in io.lines(logo_path) do + table.insert(lines, line) + end + return lines + end + + -- Read the ASCII art from the logo file + local ascii_art_lines = read_ascii_art(M.logo) + + -- Add the ASCII art to the dashboard header + dashboard.section.header.val = ascii_art_lines + + -- Add the dashboard buttons -- stylua: ignore start dashboard.section.buttons.val = { ---@diagnostic disable: param-type-mismatch @@ -43,13 +49,17 @@ M.alpha = { dashboard.button("l", "󰒲 " .. " Lazy", " Lazy "), dashboard.button("q", " " .. " Quit", " qa "), } - -- stylua: ignore end for _, button in ipairs(dashboard.section.buttons.val) do button.opts.hl = "AlphaButtons" button.opts.hl_shortcut = "AlphaShortcut" end - dashboard.section.header.opts.hl = "Conditional" + -- stylua: ignore end + + -- Set up highlight groups for the dashboard + dashboard.section.header.opts.hl = "Conditional" or "AlphaHeader" dashboard.section.footer.opts.hl = "AlphaFooter" + + -- Set up the dashboard layout padding local padding = vim.fn.max({ 2, vim.fn.floor(vim.fn.winheight(0) * 0.2) }) if vim.fn.winheight(0) < 40 then padding = 1 @@ -57,75 +67,28 @@ M.alpha = { padding = 0 end dashboard.opts.layout[1].val = padding + + -- Return the dashboard options return dashboard end, } +--- Dashboard-nvim plugin configuration M.dashboard_nvim = { + -- stylua: ignore start choices = { - { -- Find File - action = 'lua LazyVim.pick("find_files")()', - desc = " Find File", - icon = " ", - key = "f", - }, - { -- New File - action = "ene | startinsert", - desc = " New File", - icon = " ", - key = "n", - }, - { -- Open Recent Files - action = 'lua LazyVim.pick("oldfiles")()', - desc = " Recent Files", - icon = " ", - key = "r", - }, - { -- Find Text - action = 'lua LazyVim.pick("live_grep")()', - desc = " Find Text", - icon = " ", - key = "g", - }, - { -- LazyGit - action = "LazyGit", - desc = " LazyGit", - icon = " ", - key = "z", - }, - { -- Config - action = "lua LazyVim.pick.config_files()()", - desc = " Config", - icon = " ", - key = "c", - }, - { -- Restore Session - action = 'lua require("persistence").load()', - desc = " Restore Session", - icon = "󰶮 ", - key = "s", - }, - { -- Remote Session - action = 'lua require("config.rootiest").load_remote()', - desc = " Remote Session", - icon = " ", - key = "s", - }, - { -- Lazy - action = "Lazy", - desc = " Lazy", - icon = "󰒲 ", - key = "l", - }, - { -- Quit - action = function() - vim.api.nvim_input("qa") - end, - desc = " Quit", - icon = " ", - key = "q", - }, + { action = 'lua LazyVim.pick("find_files")()', desc = " Find File", icon = " ", key = "f"}, + { action = "ene | startinsert", desc = " New File", icon = " ", key = "n"}, + { action = 'lua LazyVim.pick("oldfiles")()', desc = " Recent Files", icon = " ", key = "r"}, + { action = 'lua LazyVim.pick("live_grep")()', desc = " Find Text", icon = " ", key = "g"}, + { action = "LazyGit", desc = " LazyGit", icon = " ", key = "z"}, + { action = "lua LazyVim.pick.config_files()()", desc = " Config", icon = " ", key = "c"}, + { action = 'lua require("persistence").load()', desc = " Restore Session", icon = "󰶮 ", key = "s"}, + { action = 'lua require("config.rootiest").load_remote()', desc = " Remote Session", icon = " ", key = "s"}, + { action = "Lazy", desc = " Lazy", icon = "󰒲 ", key = "l"}, + { action = function() vim.api.nvim_input("qa") end, desc = " Quit", icon = " ", key = "q"}, }, + -- stylua: ignore end } return M diff --git a/lua/plugins/cmp.lua b/lua/plugins/cmp.lua index 2b5b642..3e2f3e8 100644 --- a/lua/plugins/cmp.lua +++ b/lua/plugins/cmp.lua @@ -49,7 +49,7 @@ return { -- cmp end) local border_opts = { - border = "rounded", + border = vim.g.completion_borders or "rounded", } local window_opts = { completion = cmp.config.window.bordered(border_opts), @@ -75,7 +75,7 @@ return { -- cmp end, }, completion = { completeopt = "menu,menuone,noinsert" }, - window = vim.g.completion_round_borders_enabled and window_opts or {}, + window = vim.g.completion_borders == "rounded" and window_opts or {}, mapping = cmp.mapping.preset.insert({ [""] = cmp.mapping.select_next_item(), [""] = cmp.mapping.select_prev_item(), diff --git a/lua/plugins/dashboard/alpha.lua b/lua/plugins/dashboard/alpha.lua index 3c08f4b..bafc5b9 100644 --- a/lua/plugins/dashboard/alpha.lua +++ b/lua/plugins/dashboard/alpha.lua @@ -6,8 +6,12 @@ return { -- Alpha "goolord/alpha-nvim", event = "VimEnter", - enabled = true, - opts = require("data").dash.alpha.opts, + enabled = require("data.func").check_global_var( + "dashboard", + "alpha", + "alpha" + ), + opts = require("data.dash").alpha.opts, config = function(_, dashboard) -- close Lazy and re-open when the dashboard is ready if vim.o.filetype == "lazy" then diff --git a/lua/plugins/dashboard/nvim-dashboard.lua b/lua/plugins/dashboard/nvim-dashboard.lua index 1b96799..de4738e 100644 --- a/lua/plugins/dashboard/nvim-dashboard.lua +++ b/lua/plugins/dashboard/nvim-dashboard.lua @@ -3,7 +3,6 @@ -- ╭─────────────────────────────────────────────────────────╮ -- │ Dashboard │ -- ╰─────────────────────────────────────────────────────────╯ -local data = require("data") return { -- -- Dashboard @@ -65,7 +64,7 @@ return { -- file_height = logo_dimensions.height, }, config = { - center = data.dash.dashboard_nvim.choices, + center = require("data.dash").dashboard_nvim.choices, footer = function() local stats = require("lazy").stats() local ms = (math.floor(stats.startuptime * 100 + 0.5) / 100) @@ -111,5 +110,9 @@ return { -- return opts end, - enabled = false, + enabled = require("data.func").check_global_var( + "dashboard", + "nvim-dashboard", + "alpha" + ), } diff --git a/lua/utils/highlight.lua b/lua/utils/highlight.lua index f10f57d..cec4520 100644 --- a/lua/utils/highlight.lua +++ b/lua/utils/highlight.lua @@ -81,12 +81,6 @@ function M.setup_indent_highlight() }, scope = { enabled = false, - -- show_start = true, - -- highlight = { - -- "IndentsScopeHighlight", - -- "IndentsScopeHighlight", - -- }, - -- char = vim.g.scope_char or data.types.ibl.scope_char.hard, }, exclude = { filetypes = data.types.highlights.exclude, @@ -115,9 +109,6 @@ function M.setup_indent_highlight() }, }) - -- Set colorcolumn - vim.cmd(":set colorcolumn=120") - -- Set NeoCodeium suggestion highlight vim.api.nvim_set_hl(0, "NeoCodeiumSuggestion", { link = "Comment" })