From 18ba123a17d3bc8a74299d8dbffa9a90043a1810 Mon Sep 17 00:00:00 2001 From: hlstwizard Date: Fri, 3 Apr 2026 11:13:58 +0800 Subject: [PATCH] Refactor custom plugin enable/disable layout Adopt nginx-style plugin folders by importing only custom.plugins.enable and moving inactive specs to custom/plugins/disable. This keeps persistence disabled by default and documents the workflow in AGENTS plus local plugin notes. --- AGENTS.md | 5 ++-- init.lua | 4 +-- .../{oil.lua.disable => disable/oil.lua} | 20 +++++-------- .../plugins/{ => disable}/persistence.lua | 0 .../{tree.lua.disable => disable/tree.lua} | 0 lua/custom/plugins/{ => enable}/blame.lua | 0 lua/custom/plugins/{ => enable}/codediff.lua | 0 lua/custom/plugins/{ => enable}/diffview.lua | 0 lua/custom/plugins/{ => enable}/lint.lua | 0 lua/custom/plugins/{ => enable}/neotree.lua | 0 lua/custom/plugins/{ => enable}/opencode.lua | 30 +++++++++---------- .../plugins/{ => enable}/toggleterm.lua | 0 lua/custom/plugins/init.lua | 7 +++-- 13 files changed, 31 insertions(+), 35 deletions(-) rename lua/custom/plugins/{oil.lua.disable => disable/oil.lua} (86%) rename lua/custom/plugins/{ => disable}/persistence.lua (100%) rename lua/custom/plugins/{tree.lua.disable => disable/tree.lua} (100%) rename lua/custom/plugins/{ => enable}/blame.lua (100%) rename lua/custom/plugins/{ => enable}/codediff.lua (100%) rename lua/custom/plugins/{ => enable}/diffview.lua (100%) rename lua/custom/plugins/{ => enable}/lint.lua (100%) rename lua/custom/plugins/{ => enable}/neotree.lua (100%) rename lua/custom/plugins/{ => enable}/opencode.lua (81%) rename lua/custom/plugins/{ => enable}/toggleterm.lua (100%) diff --git a/AGENTS.md b/AGENTS.md index ceee174d..620486be 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -118,7 +118,7 @@ Do not remove useful annotations just to reduce lines. - Modules/files: - lower_snake_case for filenames where practical. - - plugin files grouped by feature in `lua/custom/plugins/`. + - plugin files grouped by feature under `lua/custom/plugins/enable/` (active) and `lua/custom/plugins/disable/` (inactive). - Local variables/functions: - descriptive lower_snake_case. - short names only for conventional temporary values (`buf`, `opts`, `client`). @@ -138,7 +138,8 @@ Do not remove useful annotations just to reduce lines. ## Plugin and Dependency Conventions - Add plugins through `lazy` specs, keeping structure consistent with existing blocks. -- When adding a new plugin, prefer putting it under `lua/custom/plugins/*.lua` (or other custom modules) instead of editing upstream kickstart blocks in `init.lua`, to minimize merge conflicts with upstream updates. +- When adding a new plugin, prefer putting it under `lua/custom/plugins/enable/*.lua` (or other custom modules) instead of editing upstream kickstart blocks in `init.lua`, to minimize merge conflicts with upstream updates. +- To disable a custom plugin without deleting its spec, move it to `lua/custom/plugins/disable/`. - Prefer minimal configuration first (`opts = {}`), then extend only if needed. - Respect platform guards (e.g., `make` checks, Windows conditionals). - Do not edit lockfile manually; let lazy manage `lazy-lock.json` updates. diff --git a/init.lua b/init.lua index 6ca9aec9..d364463c 100644 --- a/init.lua +++ b/init.lua @@ -952,11 +952,11 @@ require('lazy').setup({ require 'kickstart.plugins.neo-tree', require 'kickstart.plugins.gitsigns', -- adds gitsigns recommended keymaps - -- NOTE: The import below can automatically add your own plugins, configuration, etc from `lua/custom/plugins/*.lua` + -- NOTE: The import below automatically loads enabled custom plugins from `lua/custom/plugins/enable/*.lua` -- This is the easiest way to modularize your config. -- -- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going. - { import = 'custom.plugins' }, + { import = 'custom.plugins.enable' }, -- -- For additional information with loading, sourcing and examples see `:help lazy.nvim-🔌-plugin-spec` -- Or use telescope! diff --git a/lua/custom/plugins/oil.lua.disable b/lua/custom/plugins/disable/oil.lua similarity index 86% rename from lua/custom/plugins/oil.lua.disable rename to lua/custom/plugins/disable/oil.lua index 02455530..58333f30 100644 --- a/lua/custom/plugins/oil.lua.disable +++ b/lua/custom/plugins/disable/oil.lua @@ -7,13 +7,11 @@ return { columns = { 'icon' }, keymaps = { [''] = function() - local oil = require('oil') - local actions = require('oil.actions') + local oil = require 'oil' + local actions = require 'oil.actions' local entry = oil.get_cursor_entry() - if not entry then - return - end + if not entry then return end if entry.type == 'directory' then actions.select.callback() @@ -34,9 +32,7 @@ return { target_win = win else local target_pos = vim.api.nvim_win_get_position(target_win) - if pos[2] < target_pos[2] then - target_win = win - end + if pos[2] < target_pos[2] then target_win = win end end end end @@ -44,15 +40,13 @@ return { end if not target_win then - vim.cmd('vsplit') + vim.cmd 'vsplit' target_win = vim.api.nvim_get_current_win() vim.api.nvim_set_current_win(sidebar_win) end local dir = oil.get_current_dir() - if not dir then - return - end + if not dir then return end local path = vim.fs.joinpath(dir, entry.name) vim.api.nvim_set_current_win(target_win) @@ -73,7 +67,7 @@ return { end local current_win = vim.api.nvim_get_current_win() - vim.cmd('topleft vsplit') + vim.cmd 'topleft vsplit' local sidebar_win = vim.api.nvim_get_current_win() require('oil').open() vim.api.nvim_win_set_width(sidebar_win, 20) diff --git a/lua/custom/plugins/persistence.lua b/lua/custom/plugins/disable/persistence.lua similarity index 100% rename from lua/custom/plugins/persistence.lua rename to lua/custom/plugins/disable/persistence.lua diff --git a/lua/custom/plugins/tree.lua.disable b/lua/custom/plugins/disable/tree.lua similarity index 100% rename from lua/custom/plugins/tree.lua.disable rename to lua/custom/plugins/disable/tree.lua diff --git a/lua/custom/plugins/blame.lua b/lua/custom/plugins/enable/blame.lua similarity index 100% rename from lua/custom/plugins/blame.lua rename to lua/custom/plugins/enable/blame.lua diff --git a/lua/custom/plugins/codediff.lua b/lua/custom/plugins/enable/codediff.lua similarity index 100% rename from lua/custom/plugins/codediff.lua rename to lua/custom/plugins/enable/codediff.lua diff --git a/lua/custom/plugins/diffview.lua b/lua/custom/plugins/enable/diffview.lua similarity index 100% rename from lua/custom/plugins/diffview.lua rename to lua/custom/plugins/enable/diffview.lua diff --git a/lua/custom/plugins/lint.lua b/lua/custom/plugins/enable/lint.lua similarity index 100% rename from lua/custom/plugins/lint.lua rename to lua/custom/plugins/enable/lint.lua diff --git a/lua/custom/plugins/neotree.lua b/lua/custom/plugins/enable/neotree.lua similarity index 100% rename from lua/custom/plugins/neotree.lua rename to lua/custom/plugins/enable/neotree.lua diff --git a/lua/custom/plugins/opencode.lua b/lua/custom/plugins/enable/opencode.lua similarity index 81% rename from lua/custom/plugins/opencode.lua rename to lua/custom/plugins/enable/opencode.lua index d62b4c81..2b77d4af 100644 --- a/lua/custom/plugins/opencode.lua +++ b/lua/custom/plugins/enable/opencode.lua @@ -25,8 +25,6 @@ return { }, }, config = function() - local layout = require 'custom.layout' - ---@type opencode.Opts vim.g.opencode_opts = { server = { @@ -63,18 +61,20 @@ return { vim.keymap.set('n', '+', '', { desc = 'Increment under cursor', noremap = true }) vim.keymap.set('n', '-', '', { desc = 'Decrement under cursor', noremap = true }) - vim.api.nvim_create_autocmd('VimEnter', { - callback = function() - local argv = vim.fn.argv() - local first_arg = argv[1] - if vim.fn.argc() == 1 and type(first_arg) == 'string' and vim.fn.isdirectory(first_arg) == 1 then - vim.schedule(function() - layout.focus_main_window() - require('opencode').toggle() - layout.focus_main_window() - end) - end - end, - }) + -- Disabled: startup session/window orchestration is handled by persistence workflow. + -- vim.api.nvim_create_autocmd('VimEnter', { + -- callback = function() + -- local layout = require 'custom.layout' + -- local argv = vim.fn.argv() + -- local first_arg = argv[1] + -- if vim.fn.argc() == 1 and type(first_arg) == 'string' and vim.fn.isdirectory(first_arg) == 1 then + -- vim.schedule(function() + -- layout.focus_main_window() + -- require('opencode').toggle() + -- layout.focus_main_window() + -- end) + -- end + -- end, + -- }) end, } diff --git a/lua/custom/plugins/toggleterm.lua b/lua/custom/plugins/enable/toggleterm.lua similarity index 100% rename from lua/custom/plugins/toggleterm.lua rename to lua/custom/plugins/enable/toggleterm.lua diff --git a/lua/custom/plugins/init.lua b/lua/custom/plugins/init.lua index b3ddcfdd..eb0f0ba8 100644 --- a/lua/custom/plugins/init.lua +++ b/lua/custom/plugins/init.lua @@ -1,7 +1,8 @@ --- You can add your own plugins here or in other files in this directory! --- I promise not to create any merge conflicts in this directory :) +-- Custom plugin layout (nginx style): +-- - enable/*.lua : loaded by lazy via `import = 'custom.plugins.enable'` +-- - disable/*.lua: not imported; keep plugin specs here to disable quickly -- --- See the kickstart.nvim README for more information +-- See init.lua import config for details. ---@module 'lazy' ---@type LazySpec