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.
This commit is contained in:
hlstwizard 2026-04-03 11:13:58 +08:00
parent 1c3c4c11e7
commit 18ba123a17
13 changed files with 31 additions and 35 deletions

View File

@ -118,7 +118,7 @@ Do not remove useful annotations just to reduce lines.
- Modules/files: - Modules/files:
- lower_snake_case for filenames where practical. - 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: - Local variables/functions:
- descriptive lower_snake_case. - descriptive lower_snake_case.
- short names only for conventional temporary values (`buf`, `opts`, `client`). - 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 ## Plugin and Dependency Conventions
- Add plugins through `lazy` specs, keeping structure consistent with existing blocks. - 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. - Prefer minimal configuration first (`opts = {}`), then extend only if needed.
- Respect platform guards (e.g., `make` checks, Windows conditionals). - Respect platform guards (e.g., `make` checks, Windows conditionals).
- Do not edit lockfile manually; let lazy manage `lazy-lock.json` updates. - Do not edit lockfile manually; let lazy manage `lazy-lock.json` updates.

View File

@ -952,11 +952,11 @@ require('lazy').setup({
require 'kickstart.plugins.neo-tree', require 'kickstart.plugins.neo-tree',
require 'kickstart.plugins.gitsigns', -- adds gitsigns recommended keymaps 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. -- 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. -- 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` -- For additional information with loading, sourcing and examples see `:help lazy.nvim-🔌-plugin-spec`
-- Or use telescope! -- Or use telescope!

View File

@ -7,13 +7,11 @@ return {
columns = { 'icon' }, columns = { 'icon' },
keymaps = { keymaps = {
['<CR>'] = function() ['<CR>'] = function()
local oil = require('oil') local oil = require 'oil'
local actions = require('oil.actions') local actions = require 'oil.actions'
local entry = oil.get_cursor_entry() local entry = oil.get_cursor_entry()
if not entry then if not entry then return end
return
end
if entry.type == 'directory' then if entry.type == 'directory' then
actions.select.callback() actions.select.callback()
@ -34,9 +32,7 @@ return {
target_win = win target_win = win
else else
local target_pos = vim.api.nvim_win_get_position(target_win) local target_pos = vim.api.nvim_win_get_position(target_win)
if pos[2] < target_pos[2] then if pos[2] < target_pos[2] then target_win = win end
target_win = win
end
end end
end end
end end
@ -44,15 +40,13 @@ return {
end end
if not target_win then if not target_win then
vim.cmd('vsplit') vim.cmd 'vsplit'
target_win = vim.api.nvim_get_current_win() target_win = vim.api.nvim_get_current_win()
vim.api.nvim_set_current_win(sidebar_win) vim.api.nvim_set_current_win(sidebar_win)
end end
local dir = oil.get_current_dir() local dir = oil.get_current_dir()
if not dir then if not dir then return end
return
end
local path = vim.fs.joinpath(dir, entry.name) local path = vim.fs.joinpath(dir, entry.name)
vim.api.nvim_set_current_win(target_win) vim.api.nvim_set_current_win(target_win)
@ -73,7 +67,7 @@ return {
end end
local current_win = vim.api.nvim_get_current_win() 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() local sidebar_win = vim.api.nvim_get_current_win()
require('oil').open() require('oil').open()
vim.api.nvim_win_set_width(sidebar_win, 20) vim.api.nvim_win_set_width(sidebar_win, 20)

View File

@ -25,8 +25,6 @@ return {
}, },
}, },
config = function() config = function()
local layout = require 'custom.layout'
---@type opencode.Opts ---@type opencode.Opts
vim.g.opencode_opts = { vim.g.opencode_opts = {
server = { server = {
@ -63,18 +61,20 @@ return {
vim.keymap.set('n', '+', '<C-a>', { desc = 'Increment under cursor', noremap = true }) vim.keymap.set('n', '+', '<C-a>', { desc = 'Increment under cursor', noremap = true })
vim.keymap.set('n', '-', '<C-x>', { desc = 'Decrement under cursor', noremap = true }) vim.keymap.set('n', '-', '<C-x>', { desc = 'Decrement under cursor', noremap = true })
vim.api.nvim_create_autocmd('VimEnter', { -- Disabled: startup session/window orchestration is handled by persistence workflow.
callback = function() -- vim.api.nvim_create_autocmd('VimEnter', {
local argv = vim.fn.argv() -- callback = function()
local first_arg = argv[1] -- local layout = require 'custom.layout'
if vim.fn.argc() == 1 and type(first_arg) == 'string' and vim.fn.isdirectory(first_arg) == 1 then -- local argv = vim.fn.argv()
vim.schedule(function() -- local first_arg = argv[1]
layout.focus_main_window() -- if vim.fn.argc() == 1 and type(first_arg) == 'string' and vim.fn.isdirectory(first_arg) == 1 then
require('opencode').toggle() -- vim.schedule(function()
layout.focus_main_window() -- layout.focus_main_window()
end) -- require('opencode').toggle()
end -- layout.focus_main_window()
end, -- end)
}) -- end
-- end,
-- })
end, end,
} }

View File

@ -1,7 +1,8 @@
-- You can add your own plugins here or in other files in this directory! -- Custom plugin layout (nginx style):
-- I promise not to create any merge conflicts in this directory :) -- - 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' ---@module 'lazy'
---@type LazySpec ---@type LazySpec