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:
- 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.

View File

@ -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!

View File

@ -7,13 +7,11 @@ return {
columns = { 'icon' },
keymaps = {
['<CR>'] = 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)

View File

@ -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', '+', '<C-a>', { desc = 'Increment under cursor', noremap = true })
vim.keymap.set('n', '-', '<C-x>', { 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,
}

View File

@ -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