From baf431168ab0e10c5302da24de2d689eb1e2a642 Mon Sep 17 00:00:00 2001 From: Cian Hughes Date: Mon, 22 Dec 2025 17:08:53 +0000 Subject: [PATCH] Attempt to refactor config to be more maintainable --- lua/plugins/{utils.lua => coding.lua} | 148 +++++++------------------- lua/plugins/command.lua | 3 + lua/plugins/editor.lua | 108 +++++++++++++++++++ lua/plugins/extras.lua | 72 ------------- lua/plugins/lang/kitty.lua | 3 + lua/plugins/lang/lua.lua | 10 ++ lua/plugins/lang/markdown.lua | 14 +++ lua/plugins/lang/nix.lua | 10 ++ lua/plugins/lang/python.lua | 21 ++++ lua/plugins/lang/rust.lua | 4 + lua/plugins/lang/scallop.lua | 3 + lua/plugins/lsp.lua | 2 - lua/plugins/ui.lua | 9 ++ 13 files changed, 223 insertions(+), 184 deletions(-) rename lua/plugins/{utils.lua => coding.lua} (52%) create mode 100644 lua/plugins/command.lua create mode 100644 lua/plugins/editor.lua delete mode 100644 lua/plugins/extras.lua create mode 100644 lua/plugins/lang/kitty.lua create mode 100644 lua/plugins/lang/lua.lua create mode 100644 lua/plugins/lang/markdown.lua create mode 100644 lua/plugins/lang/nix.lua create mode 100644 lua/plugins/lang/python.lua create mode 100644 lua/plugins/lang/rust.lua create mode 100644 lua/plugins/lang/scallop.lua diff --git a/lua/plugins/utils.lua b/lua/plugins/coding.lua similarity index 52% rename from lua/plugins/utils.lua rename to lua/plugins/coding.lua index 8094c29..da6c12c 100644 --- a/lua/plugins/utils.lua +++ b/lua/plugins/coding.lua @@ -1,15 +1,13 @@ -return { -- General programming utilities go here - -- Tools for configuration and plugin development - { - "klen/nvim-config-local", - lazy = false, -- Load immediately to ensure it catches the initial working directory +return { + { -- Autoformat + "stevearc/conform.nvim", + event = "VimEnter", opts = { - config_files = { ".nvim.lua", ".nvimrc", ".exrc" }, - hashfile = vim.fn.stdpath("data") .. "/config-local", - autocommands_create = true, - commands_create = true, - silent = false, - lookup_parents = true, + notify_on_error = false, + format_on_save = { + timeout_ms = 500, + lsp_fallback = true, + }, }, }, { @@ -22,60 +20,6 @@ return { -- General programming utilities go here }, }, }, - -- Privilege escalation plugin - { "lambdalisue/suda.vim", event = "VeryLazy" }, - { - "folke/trouble.nvim", - cmd = { "Trouble" }, - opts = { - modes = { - lsp = { - win = { position = "right" }, - }, - }, - }, - keys = require("config.keys").trouble, - }, - { - "folke/todo-comments.nvim", - cmd = { "TodoTrouble", "TodoTelescope" }, - event = "VimEnter", - dependencies = { "nvim-lua/plenary.nvim" }, - keys = require("config.keys").todo_comments, - }, - { - "lewis6991/gitsigns.nvim", - event = "VimEnter", - dependencies = { "nvim-lua/plenary.nvim" }, - config = function() - require("gitsigns").setup({ - signs = { - add = { text = "┃" }, - change = { text = "┃" }, - delete = { text = "_" }, - topdelete = { text = "‾" }, - changedelete = { text = "~" }, - }, - }) - end, - keys = require("config.keys").gitsigns, - }, - { -- Oil is a very nice buffer-based filetree editor - "stevearc/oil.nvim", - event = "VeryLazy", - opts = {}, - dependencies = { "nvim-tree/nvim-web-devicons" }, - keys = require("config.keys").oil, - }, - { -- Harpoon, because i keep losing track of my markers - "theprimeagen/harpoon", - branch = "harpoon2", - dependencies = { "nvim-lua/plenary.nvim" }, - config = function() - require("harpoon"):setup({}) - end, - keys = require("config.keys").harpoon, - }, { -- Package and devenv plugins "danymat/neogen", event = "VimEnter", @@ -94,27 +38,37 @@ return { -- General programming utilities go here end, keys = require("config.keys").neogen, }, - { -- Autoformat - "stevearc/conform.nvim", - event = "VimEnter", - opts = { - notify_on_error = false, - format_on_save = { - timeout_ms = 500, - lsp_fallback = true, - }, - formatters_by_ft = { - lua = { "stylua" }, - nix = { "alejandra" }, - -- Conform can also run multiple formatters sequentially - -- python = { "isort", "black" }, - -- - -- You can use a sub-list to tell conform to run *until* a formatter - -- is found. - -- javascript = { { "prettierd", "prettier" } }, - }, + { -- A plugin to integrate tests is helpful, so i'm adding neotest + "nvim-neotest/neotest", + event = "VeryLazy", + dependencies = { + "nvim-neotest/nvim-nio", + "nvim-lua/plenary.nvim", + "antoinemadec/FixCursorHold.nvim", + "nvim-treesitter/nvim-treesitter", }, }, + { -- Tools for configuration and plugin development + "klen/nvim-config-local", + lazy = false, -- Load immediately to ensure it catches the initial working directory + opts = { + config_files = { ".nvim.lua", ".nvimrc", ".exrc" }, + hashfile = vim.fn.stdpath("data") .. "/config-local", + autocommands_create = true, + commands_create = true, + silent = false, + lookup_parents = true, + }, + }, + { -- Add Overseer as a task running tool + "stevearc/overseer.nvim", + event = "VeryLazy", + opts = {}, + config = function() + require("overseer").setup() + end, + keys = require("config.keys").overseer, + }, { -- Highlight, edit, and navigate code "nvim-treesitter/nvim-treesitter", build = ":TSUpdate", @@ -132,30 +86,4 @@ return { -- General programming utilities go here { "nushell/tree-sitter-nu", build = ":TSUpdate nu" }, }, }, - { -- Undo tree - "mbbill/undotree", - event = "VeryLazy", - keys = require("config.keys").undotree, - }, - { -- Add Overseer as a task running tool - "stevearc/overseer.nvim", - event = "VeryLazy", - opts = {}, - config = function() - require("overseer").setup() - end, - keys = require("config.keys").overseer, - }, - { -- A plugin to integrate tests is helpful, so i'm adding neotest - "nvim-neotest/neotest", - event = "VeryLazy", - dependencies = { - "nvim-neotest/nvim-nio", - "nvim-lua/plenary.nvim", - "antoinemadec/FixCursorHold.nvim", - "nvim-treesitter/nvim-treesitter", - }, - }, - -- Rust tools like inlay hints are absolutely essential - { "mrcjkb/rustaceanvim", version = "^6", lazy = false }, } diff --git a/lua/plugins/command.lua b/lua/plugins/command.lua new file mode 100644 index 0000000..d3d7738 --- /dev/null +++ b/lua/plugins/command.lua @@ -0,0 +1,3 @@ +return { + { "lambdalisue/suda.vim", event = "VeryLazy" }, -- Privilege escalation plugin +} diff --git a/lua/plugins/editor.lua b/lua/plugins/editor.lua new file mode 100644 index 0000000..7df071d --- /dev/null +++ b/lua/plugins/editor.lua @@ -0,0 +1,108 @@ +return { + { + "lewis6991/gitsigns.nvim", + event = "VimEnter", + dependencies = { "nvim-lua/plenary.nvim" }, + config = function() + require("gitsigns").setup({ + signs = { + add = { text = "┃" }, + change = { text = "┃" }, + delete = { text = "_" }, + topdelete = { text = "‾" }, + changedelete = { text = "~" }, + }, + }) + end, + keys = require("config.keys").gitsigns, + }, + { -- Harpoon, because i keep losing track of my markers + "theprimeagen/harpoon", + branch = "harpoon2", + dependencies = { "nvim-lua/plenary.nvim" }, + config = function() + require("harpoon"):setup({}) + end, + keys = require("config.keys").harpoon, + }, + { -- Definitely need to add a plugin for quickly making notes in obsidian + "epwalsh/obsidian.nvim", + version = "*", + cmd = "Obsidian", + event = "VeryLazy", + cond = function() + return vim.fn.executable("obsidian") == 1 + end, + dependencies = { + "nvim-lua/plenary.nvim", + "nvim-telescope/telescope.nvim", + "nvim-treesitter/nvim-treesitter", + }, + opts = function() + local target_path = vim.fn.expand("~/Documents/Work_Notes/") + local workspaces = {} + + if vim.fn.isdirectory(target_path) == 1 then + table.insert(workspaces, { + name = "work", + path = target_path, + }) + end + + if #workspaces == 0 then + local fallback_path = vim.fn.stdpath("data") .. "/obsidian_fallback" + if vim.fn.isdirectory(fallback_path) == 0 then + vim.fn.mkdir(fallback_path, "p") + end + + table.insert(workspaces, { + name = "fallback", + path = fallback_path, + }) + + vim.notify( + "Obsidian: 'Work_Notes' not found. Using fallback path.", + vim.log.levels.WARN + ) + end + + return { + workspaces = workspaces, + completion = { + min_chars = 2, + }, + } + end, + }, + { -- Oil is a very nice buffer-based filetree editor + "stevearc/oil.nvim", + event = "VeryLazy", + opts = {}, + dependencies = { "nvim-tree/nvim-web-devicons" }, + keys = require("config.keys").oil, + }, + { + "folke/todo-comments.nvim", + cmd = { "TodoTrouble", "TodoTelescope" }, + event = "VimEnter", + dependencies = { "nvim-lua/plenary.nvim" }, + keys = require("config.keys").todo_comments, + }, + { + "folke/trouble.nvim", + cmd = { "Trouble" }, + opts = { + modes = { + lsp = { + win = { position = "right" }, + }, + }, + }, + keys = require("config.keys").trouble, + }, + { -- Undo tree + "mbbill/undotree", + event = "VeryLazy", + keys = require("config.keys").undotree, + }, +} diff --git a/lua/plugins/extras.lua b/lua/plugins/extras.lua deleted file mode 100644 index 2ca5b7f..0000000 --- a/lua/plugins/extras.lua +++ /dev/null @@ -1,72 +0,0 @@ -return { -- Non programming quality of life utilities go here - { -- Definitely need to add a plugin for quickly making notes in obsidian - "epwalsh/obsidian.nvim", - version = "*", - cmd = "Obsidian", - event = "VeryLazy", - cond = function() - return vim.fn.executable("obsidian") == 1 - end, - dependencies = { - "nvim-lua/plenary.nvim", - "nvim-telescope/telescope.nvim", - "nvim-treesitter/nvim-treesitter", - }, - opts = function() - local target_path = vim.fn.expand("~/Documents/Work_Notes/") - local workspaces = {} - - if vim.fn.isdirectory(target_path) == 1 then - table.insert(workspaces, { - name = "work", - path = target_path, - }) - end - - if #workspaces == 0 then - local fallback_path = vim.fn.stdpath("data") .. "/obsidian_fallback" - if vim.fn.isdirectory(fallback_path) == 0 then - vim.fn.mkdir(fallback_path, "p") - end - - table.insert(workspaces, { - name = "fallback", - path = fallback_path, - }) - - vim.notify( - "Obsidian: 'Work_Notes' not found. Using fallback path.", - vim.log.levels.WARN - ) - end - - return { - workspaces = workspaces, - completion = { - min_chars = 2, - }, - } - end, - }, - { - "MeanderingProgrammer/render-markdown.nvim", - opts = {}, - ft = "markdown", - dependencies = { - "nvim-treesitter/nvim-treesitter", - "echasnovski/mini.nvim", - "nvim-tree/nvim-web-devicons", - }, - ---@module 'render-markdown' - ---@type render.md.UserConfig - }, - { -- A cheatsheet will always be useful until im a bit more familiar with vim - "sudormrfbin/cheatsheet.nvim", - event = "VeryLazy", - dependencies = { - "nvim-telescope/telescope.nvim", - "nvim-lua/popup.nvim", - "nvim-lua/plenary.nvim", - }, - }, -} diff --git a/lua/plugins/lang/kitty.lua b/lua/plugins/lang/kitty.lua new file mode 100644 index 0000000..6bd80de --- /dev/null +++ b/lua/plugins/lang/kitty.lua @@ -0,0 +1,3 @@ +return { + { "fladson/vim-kitty", ft = "kitty" }, +} diff --git a/lua/plugins/lang/lua.lua b/lua/plugins/lang/lua.lua new file mode 100644 index 0000000..6c41efd --- /dev/null +++ b/lua/plugins/lang/lua.lua @@ -0,0 +1,10 @@ +return { + { + "stevearc/conform.nvim", + opts = { + formatters_by_ft = { + lua = { "stylua" }, + }, + }, + }, +} diff --git a/lua/plugins/lang/markdown.lua b/lua/plugins/lang/markdown.lua new file mode 100644 index 0000000..58cf07d --- /dev/null +++ b/lua/plugins/lang/markdown.lua @@ -0,0 +1,14 @@ +return { + { + "MeanderingProgrammer/render-markdown.nvim", + opts = {}, + ft = "markdown", + dependencies = { + "nvim-treesitter/nvim-treesitter", + "echasnovski/mini.nvim", + "nvim-tree/nvim-web-devicons", + }, + ---@module 'render-markdown' + ---@type render.md.UserConfig + }, +} diff --git a/lua/plugins/lang/nix.lua b/lua/plugins/lang/nix.lua new file mode 100644 index 0000000..d301035 --- /dev/null +++ b/lua/plugins/lang/nix.lua @@ -0,0 +1,10 @@ +return { + { + "stevearc/conform.nvim", + opts = { + formatters_by_ft = { + nix = { "alejandra" }, + }, + }, + }, +} diff --git a/lua/plugins/lang/python.lua b/lua/plugins/lang/python.lua new file mode 100644 index 0000000..9565cdc --- /dev/null +++ b/lua/plugins/lang/python.lua @@ -0,0 +1,21 @@ +return { + { + "benomahony/uv.nvim", + ft = { "python" }, + dependencies = { + "folke/snacks.nvim", + "nvim-telescope/telescope.nvim", + }, + opts = { + picker_integration = true, + }, + }, + { + "stevearc/conform.nvim", + opts = { + formatters_by_ft = { + python = { "ruff" }, + }, + }, + }, +} diff --git a/lua/plugins/lang/rust.lua b/lua/plugins/lang/rust.lua new file mode 100644 index 0000000..2e36638 --- /dev/null +++ b/lua/plugins/lang/rust.lua @@ -0,0 +1,4 @@ +return { + -- Analysis and inlay hints are absolutely essential + { "mrcjkb/rustaceanvim", version = "^6", lazy = false }, +} diff --git a/lua/plugins/lang/scallop.lua b/lua/plugins/lang/scallop.lua new file mode 100644 index 0000000..c30c2d4 --- /dev/null +++ b/lua/plugins/lang/scallop.lua @@ -0,0 +1,3 @@ +return { + { "scallop-lang/vim-scallop", ft = "scallop" }, +} diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua index 8e9760e..d38741d 100644 --- a/lua/plugins/lsp.lua +++ b/lua/plugins/lsp.lua @@ -56,6 +56,4 @@ return { }) end, }, - { "fladson/vim-kitty", ft = "kitty" }, - { "scallop-lang/vim-scallop", ft = "scallop" }, } diff --git a/lua/plugins/ui.lua b/lua/plugins/ui.lua index 6cfb6b5..09c0f94 100644 --- a/lua/plugins/ui.lua +++ b/lua/plugins/ui.lua @@ -7,6 +7,15 @@ return { -- UI components and other visual elements are declared here vim.cmd.colorscheme("tokyonight-night") end, }, + { -- A cheatsheet will always be useful until im a bit more familiar with vim + "sudormrfbin/cheatsheet.nvim", + event = "VeryLazy", + dependencies = { + "nvim-telescope/telescope.nvim", + "nvim-lua/popup.nvim", + "nvim-lua/plenary.nvim", + }, + }, { "MunifTanjim/nui.nvim", lazy = true }, { -- Useful plugin to show you pending keybinds. "folke/which-key.nvim",