From 0fcb172fcc0167e0df159213dedc425950e37bd3 Mon Sep 17 00:00:00 2001 From: rootiest Date: Sat, 31 Aug 2024 03:01:13 -0400 Subject: [PATCH] refactor: consolidate plugin dependencies into a central data source --- lua/plugins/ai.lua | 2 +- lua/plugins/cmp.lua | 52 +---------------------------- lua/plugins/coding.lua | 12 +++---- lua/plugins/debug.lua | 19 +++-------- lua/plugins/editor.lua | 12 +++---- lua/plugins/git.lua | 11 +++---- lua/plugins/lualine.lua | 32 +++++++++--------- lua/plugins/terminal.lua | 16 ++++----- lua/plugins/themes.lua | 70 +++++----------------------------------- lua/plugins/util.lua | 62 +++++++++++++++++------------------ 10 files changed, 79 insertions(+), 209 deletions(-) diff --git a/lua/plugins/ai.lua b/lua/plugins/ai.lua index cae7124..9ed072f 100644 --- a/lua/plugins/ai.lua +++ b/lua/plugins/ai.lua @@ -29,7 +29,7 @@ return { }, { -- Minuet-AI "milanglacier/minuet-ai.nvim", - dependencies = { { "nvim-lua/plenary.nvim" }, { "hrsh7th/nvim-cmp" } }, + dependencies = data.deps.minuet, config = function() require("minuet").setup({ provider = "openai" }) end, diff --git a/lua/plugins/cmp.lua b/lua/plugins/cmp.lua index cb23ae7..ff8521b 100644 --- a/lua/plugins/cmp.lua +++ b/lua/plugins/cmp.lua @@ -9,57 +9,7 @@ return { -- HACK: Experiemental cmp performance fork dev = true, event = "VeryLazy", - dependencies = { - { - "L3MON4D3/LuaSnip", - build = (function() - if vim.fn.has("win32") == 1 or vim.fn.executable("make") == 0 then - return - end - return "make install_jsregexp" - end)(), - dependencies = { - { - "rafamadriz/friendly-snippets", - config = function() - require("luasnip.loaders.from_vscode").lazy_load() - end, - }, - }, - }, - { - "petertriho/cmp-git", - opts = {}, - config = function() - local cmp = require("cmp") - cmp.setup.filetype("gitcommit", { - sources = cmp.config.sources({ - { name = "git", priority = 50 }, - { name = "path", priority = 40 }, - }, { - { name = "buffer", priority = 50 }, - }), - }) - end, - }, - "saadparwaiz1/cmp_luasnip", - "hrsh7th/cmp-nvim-lsp", - "hrsh7th/cmp-path", - "hrsh7th/cmp-buffer", - "onsails/lspkind.nvim", - "hrsh7th/cmp-emoji", - "hrsh7th/cmp-cmdline", - { - "chrisgrieser/cmp_yanky", - option = { - onlyCurrentFiletype = false, - }, - }, - "SergioRibera/cmp-dotenv", - "hrsh7th/cmp-calc", - "davidsierradz/cmp-conventionalcommits", - "Dynge/gitmoji.nvim", - }, + dependencies = data.deps.cmp, -- : config = function() local cmp = require("cmp") diff --git a/lua/plugins/coding.lua b/lua/plugins/coding.lua index 061edbd..db226a6 100644 --- a/lua/plugins/coding.lua +++ b/lua/plugins/coding.lua @@ -26,6 +26,9 @@ return { { -- VSCode import = "lazyvim.plugins.extras.vscode", }, + { -- Neogen + import = "lazyvim.plugins.extras.coding.neogen", + }, { -- G-code "wilriker/gcode.vim", }, @@ -42,17 +45,10 @@ return { ft = data.types.alternate, keys = data.keys.alternate, }, - { -- Highlight colors - "brenoprata10/nvim-highlight-colors", - event = "BufReadPre", - config = function() - require("nvim-highlight-colors").setup({}) - end, - }, { -- Tailwind "luckasRanarison/tailwind-tools.nvim", lazy = true, - dependencies = { "nvim-treesitter/nvim-treesitter" }, + dependencies = data.deps.needs_treesitter, opts = {}, }, { -- Substitute diff --git a/lua/plugins/debug.lua b/lua/plugins/debug.lua index 35a3fd8..87a390a 100644 --- a/lua/plugins/debug.lua +++ b/lua/plugins/debug.lua @@ -1,6 +1,8 @@ -- ╭─────────────────────────────────────────────────────────╮ -- │ Debug │ -- ╰─────────────────────────────────────────────────────────╯ +local data = require("data") + return { { -- DAP Core import = "lazyvim.plugins.extras.dap.core", @@ -15,22 +17,9 @@ return { { "nvim-neotest/neotest", opts = { - adapters = { - "neotest-plenary", - "neotest-python", - "neotest-vim-test", - "neotest-minitest", - "neotest-bash", - }, - }, - dependencies = { - "nvim-neotest/nvim-nio", - "nvim-lua/plenary.nvim", - "zidhuss/neotest-minitest", - "rcasia/neotest-bash", - "antoinemadec/FixCursorHold.nvim", - "nvim-treesitter/nvim-treesitter", + adapters = data.deps.neotest.adapters, }, + dependencies = data.deps.neotest.deps, }, { -- Profiling "stevearc/profile.nvim", diff --git a/lua/plugins/editor.lua b/lua/plugins/editor.lua index a8aac45..e1b9221 100644 --- a/lua/plugins/editor.lua +++ b/lua/plugins/editor.lua @@ -27,7 +27,7 @@ return { }, { "folke/trouble.nvim", - cmd = { "Trouble" }, + cmd = data.cmd.trouble, opts = { modes = { symbols = { -- Configure symbols mode @@ -59,7 +59,6 @@ return { ---@module "neominimap.config.meta" { -- NeoMiniMap "Isrothy/neominimap.nvim", - version = "*", lazy = false, keys = data.keys.minimap, init = data.types.minimap.init(), @@ -90,10 +89,9 @@ return { "gen740/SmoothCursor.nvim", event = "BufEnter", -- lazy = true, - config = function() - ---@diagnostic disable-next-line: missing-fields - require("smoothcursor").setup({}) - end, + opts = { + cursor = "", + }, }, { -- Smart Scrolloff "tonymajestro/smart-scrolloff.nvim", @@ -105,7 +103,7 @@ return { { -- Recorder "chrisgrieser/nvim-recorder", event = "VeryLazy", - dependencies = "rcarriga/nvim-notify", + dependencies = data.deps.recorder, opts = {}, }, { -- Comment Box diff --git a/lua/plugins/git.lua b/lua/plugins/git.lua index 24ed01f..9aab43d 100644 --- a/lua/plugins/git.lua +++ b/lua/plugins/git.lua @@ -27,10 +27,7 @@ return { lazy = true, cmd = data.cmd.lazygit, keys = data.keys.lazygit, - dependencies = { - "nvim-telescope/telescope.nvim", - "nvim-lua/plenary.nvim", - }, + dependencies = data.deps.lazygit, config = function() require("telescope").load_extension("lazygit") end, @@ -57,7 +54,7 @@ return { -- Get the current lualine configuration local config = require("lualine").get_config() local git_blame = require("gitblame") - local utils = require("utils.rootiest") + local funcs = data.func -- Define the width limit for displaying the Git blame component local width_limit = 245 -- Adjust this value as needed -- Add Git-blame to lualine_c section @@ -65,9 +62,9 @@ return { git_blame.get_current_blame_text, cond = function() -- Only show if text is available return git_blame.is_blame_text_available() - and utils.is_window_wide_enough(width_limit) + and funcs.is_window_wide_enough(width_limit) end, - color = { fg = utils.get_fg_color("GitSignsCurrentLineBlame") }, + color = { fg = funcs.get_fg_color("GitSignsCurrentLineBlame") }, padding = { left = 1, right = 0 }, on_click = function() vim.cmd("LazyGit") diff --git a/lua/plugins/lualine.lua b/lua/plugins/lualine.lua index 5892e80..898c00f 100644 --- a/lua/plugins/lualine.lua +++ b/lua/plugins/lualine.lua @@ -3,14 +3,12 @@ -- ╰─────────────────────────────────────────────────────────╯ local utils = require("utils") -local rootils = utils.rootiest +local data = require("data") +local funcs = data.func return { "nvim-lualine/lualine.nvim", - dependencies = { - { "bezhermoso/todos-lualine.nvim" }, - { "folke/todo-comments.nvim" }, - }, + dependencies = data.deps.lualine, init = function() vim.g.lualine_laststatus = vim.o.laststatus if vim.fn.argc(-1) > 0 then @@ -29,7 +27,7 @@ return { -- Define todo-comments component local todos_component = - require("todos-lualine").component(require("data").types.todo.lualine()) + require("todos-lualine").component(data.types.todo.lualine()) local opts = { options = { -- General options @@ -45,7 +43,7 @@ return { lualine_a = { { -- Mode "mode", - icon = require("data").types.logo.icon, + icon = data.types.logo.icon, padding = { left = 1, right = 0 }, }, }, @@ -58,7 +56,7 @@ return { { -- Todo todos_component, cond = function() - return rootils.is_window_wide_enough(100) + return funcs.is_window_wide_enough(100) end, padding = { left = 1, right = 0 }, on_click = function() @@ -70,7 +68,7 @@ return { return require("arrow.statusline").text_for_statusline_with_icons() end, cond = function() - return rootils.is_window_wide_enough(100) + return funcs.is_window_wide_enough(100) end, padding = { left = 1, right = 0 }, on_click = function() @@ -145,7 +143,7 @@ return { end end, cond = function() - return rootils.is_window_wide_enough(200) + return funcs.is_window_wide_enough(200) end, padding = { left = 0, right = 0 }, on_click = function() @@ -161,7 +159,7 @@ return { return utils.wakatime_stats.get_color() end, cond = function() - return rootils.is_window_wide_enough(100) + return funcs.is_window_wide_enough(100) end, padding = { left = 0, right = 1 }, }, @@ -170,7 +168,7 @@ return { return utils.music_stats.get_icon_with_text() end, cond = function() - return rootils.is_window_wide_enough(100) + return funcs.is_window_wide_enough(100) end, padding = { left = 0, right = 1 }, }, @@ -182,7 +180,7 @@ return { end, icon = " ", cond = function() - return rootils.is_window_wide_enough(80) + return funcs.is_window_wide_enough(80) end, padding = { left = 0, right = 1 }, on_click = function() @@ -194,7 +192,7 @@ return { separator = "", padding = { left = 0, right = 1 }, cond = function() - return rootils.is_window_wide_enough(60) + return funcs.is_window_wide_enough(60) end, icon = "", on_click = function() @@ -205,7 +203,7 @@ return { "location", padding = { left = 0, right = 1 }, cond = function() - return rootils.is_window_wide_enough(40) + return funcs.is_window_wide_enough(40) end, on_click = function() vim.cmd("Telescope grep_string") @@ -214,14 +212,14 @@ return { { -- Selection "selection_count", cond = function() - return rootils.is_window_wide_enough(120) + return funcs.is_window_wide_enough(120) end, padding = { left = 0, right = 1 }, }, { -- Filesize "filesize", cond = function() - return rootils.is_window_wide_enough(100) + return funcs.is_window_wide_enough(100) end, padding = { left = 0, right = 1 }, icon = "", diff --git a/lua/plugins/terminal.lua b/lua/plugins/terminal.lua index 7ab950c..5f6d109 100644 --- a/lua/plugins/terminal.lua +++ b/lua/plugins/terminal.lua @@ -1,14 +1,14 @@ -- ╭─────────────────────────────────────────────────────────╮ -- │ Terminals │ -- ╰─────────────────────────────────────────────────────────╯ -package.path = package.path - .. ";" - .. vim.fn.expand("$HOME") - .. "/.luarocks/share/lua/5.1/?/init.lua" -package.path = package.path - .. ";" - .. vim.fn.expand("$HOME") - .. "/.luarocks/share/lua/5.1/?.lua" +-- package.path = package.path +-- .. ";" +-- .. vim.fn.expand("$HOME") +-- .. "/.luarocks/share/lua/5.1/?/init.lua" +-- package.path = package.path +-- .. ";" +-- .. vim.fn.expand("$HOME") +-- .. "/.luarocks/share/lua/5.1/?.lua" local data = require("data") diff --git a/lua/plugins/themes.lua b/lua/plugins/themes.lua index dc24b01..18181e0 100644 --- a/lua/plugins/themes.lua +++ b/lua/plugins/themes.lua @@ -17,52 +17,7 @@ return { lazy = false, -- Override priority = 1000, name = "catppuccin", - background = { -- :h background - light = "latte", - dark = "frappe", - }, - integrations = { - native_lsp = { - enabled = true, - virtual_text = { - errors = { "italic" }, - hints = { "italic" }, - warnings = { "italic" }, - information = { "italic" }, - ok = { "italic" }, - }, - underlines = { - errors = { "underline" }, - hints = { "underline" }, - warnings = { "underline" }, - information = { "underline" }, - ok = { "underline" }, - }, - inlay_hints = { - background = true, - }, - }, - dadbod_ui = true, - indent_blankline = { - enabled = true, - scope_color = "mauve", - colored_indent_levels = true, - }, - grug_far = true, - mason = true, - mini = { - enabled = true, - indentscope_color = "mauve", - }, - neotree = true, - noice = true, - notify = true, - nvim_surround = true, - octo = true, - overseer = true, - rainbow_delimiters = true, - which_key = true, - }, + opts = data.types.catppuccin, }, { -- Ayu "Shatur/neovim-ayu", @@ -143,7 +98,7 @@ return { "zenbones-theme/zenbones.nvim", name = "zenbones", lazy = true, - dependencies = { "rktjmp/lush.nvim" }, + dependencies = data.deps.zenbones, }, -- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ UTILITIES ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ { -- Transparent @@ -155,21 +110,12 @@ return { { -- Auto Dark Mode "f-person/auto-dark-mode.nvim", lazy = true, - opts = { - update_interval = 2000, - set_dark_mode = function() - vim.o.background = "dark" - vim.cmd.colorscheme( - require("astral").colortheme or "catppuccin-mocha" or "tokyonight" - ) - end, - set_light_mode = function() - vim.o.background = "light" - vim.cmd.colorscheme( - require("astral").colortheme or "catppuccin-latte" or "tokyonight-day" - ) - end, - }, + opts = data.types.auto_dark_mode, cond = not data.func.is_ssh(), }, + { -- Highlight colors + "brenoprata10/nvim-highlight-colors", + event = "BufReadPre", + opts = data.types.hightlight_colors, + }, } diff --git a/lua/plugins/util.lua b/lua/plugins/util.lua index 0509c8c..bd43151 100644 --- a/lua/plugins/util.lua +++ b/lua/plugins/util.lua @@ -1,6 +1,7 @@ -- ╭─────────────────────────────────────────────────────────╮ -- │ Utilities │ -- ╰─────────────────────────────────────────────────────────╯ +local data = require("data") return { { -- Chezmoi @@ -16,17 +17,17 @@ return { { -- Link following "chrishrb/gx.nvim", lazy = true, - cmd = require("data.cmd").gx, - keys = require("data.keys").gx, + cmd = data.cmd.gx, + keys = data.keys.gx, init = function() vim.g.netrw_nogx = 1 end, - dependencies = { "nvim-lua/plenary.nvim" }, + dependencies = data.deps.gx, config = true, }, { -- Auto-save "okuuva/auto-save.nvim", - cmd = require("data.cmd").autosave, + cmd = data.cmd.autosave, event = { "InsertLeave", "TextChanged" }, opts = { execution_message = { @@ -37,8 +38,8 @@ return { { -- Ripgrep substitute "chrisgrieser/nvim-rip-substitute", event = "InsertEnter", - cmd = require("data.cmd").ripsub, - keys = require("data.keys").ripsub, + cmd = data.cmd.ripsub, + keys = data.keys.ripsub, }, { -- Unception "samjwill/nvim-unception", @@ -49,10 +50,8 @@ return { { -- 🍎 Icon Picker "ziontee113/icon-picker.nvim", lazy = true, - config = function() - require("icon-picker").setup({ disable_legacy_commands = true }) - end, - keys = require("data.keys").iconpicker, + opts = { disable_legacy_commands = true }, + keys = data.keys.iconpicker, }, { -- Codesnap "mistricky/codesnap.nvim", @@ -67,19 +66,17 @@ return { code_font_family = "Iosevka NF", code_font_size = 12, }, - cmd = require("data.cmd").codesnap, - keys = require("data.keys").codesnap, + cmd = data.cmd.codesnap, + keys = data.keys.codesnap, }, { -- Kulala "mistweaverco/kulala.nvim", - event = "InsertEnter", - config = function() - require("kulala").setup() - end, + ft = { "http", "https", "ftp", "ftps" }, + opts = {}, }, { -- Hardtime "m4xshen/hardtime.nvim", - dependencies = { "MunifTanjim/nui.nvim", "nvim-lua/plenary.nvim" }, + dependencies = data.deps.hardtime, opts = function() return { enabled = vim.g.usehardtime } end, @@ -88,19 +85,19 @@ return { "dmtrKovalenko/caps-word.nvim", lazy = true, opts = {}, - keys = require("data.keys").capsword, + keys = data.keys.capsword, }, { -- Music Controls "AntonVanAssche/music-controls.nvim", - dependencies = { "rcarriga/nvim-notify" }, + dependencies = data.deps.musiccontrols, opts = { default_player = "YoutubeMusic", }, }, { -- Qalc "Apeiros-46B/qalc.nvim", - cmd = require("data.cmd").qalc, - keys = require("data.keys").qalc, + cmd = data.cmd.qalc, + keys = data.keys.qalc, opts = { set_ft = "qalc", }, @@ -109,11 +106,7 @@ return { "amitds1997/remote-nvim.nvim", lazy = true, version = "*", -- Pin to GitHub releases - dependencies = { - "nvim-lua/plenary.nvim", -- For standard functions - "MunifTanjim/nui.nvim", -- To build the plugin UI - "nvim-telescope/telescope.nvim", -- For picking b/w different remote methods - }, + dependencies = data.deps.remotenvim, config = true, }, { -- Encourage @@ -123,9 +116,7 @@ return { { -- Helpview "OXY2DEV/helpview.nvim", ft = "help", - dependencies = { - "nvim-treesitter/nvim-treesitter", - }, + dependencies = data.deps.needs_treesitter, }, { -- Docker-compose logs "adelowo/dockercomposelogs.nvim", @@ -133,12 +124,17 @@ return { require("dockercomposelogs").setup({}) end, event = "VeryLazy", - dependencies = { - "nvim-telescope/telescope.nvim", - }, + dependencies = data.deps.needs_telescope, }, { -- Suda "lambdalisue/vim-suda", - cmd = require("data.cmd").suda, + cmd = data.cmd.suda, + }, + { -- Spell checker + "matkrin/telescope-spell-errors.nvim", + config = function() + require("telescope").load_extension("spell_errors") + end, + dependencies = data.deps.needs_telescope, }, }