移除 vim-fugitive 和 mini.diff,引入三层 Git 工具栈(对齐 nvchad 分支): - gitsigns.nvim:buffer 级 inline gutter + hunk 操作(BufReadPost 懒加载) - neogit:仓库级 status 客户端(<leader>gg,依赖 plenary) - codediff.nvim:文件级 side-by-side diff(<leader>gd/gD) 键位变更: - ghs/ghr/ghp/ghb/ghB/ghd/ghD + ]h/[h 改由 gitsigns 提供 - <leader>gg → Neogit、<leader>gd/gD → CodeDiff - 移除 <leader>gl(GcLog,由 neogit 内部 log 视图取代) 三个独立插件统一采用 load_X() → packadd → require().setup() 加载风格
3.4 KiB
3.4 KiB
AGENTS.md
This is a personal Neovim configuration targeting Neovim 0.12+. It lives at ~/.config/nvim and is not a traditional software project — there is no build system, test suite, or package manager outside Neovim itself.
Critical Architecture Notes
- Plugin manager: Neovim 0.12+ built-in
vim.pack(not lazy.nvim / packer). Plugins are declared inlua/pack.luaviavim.pack.add({ urls }, { load = false })and tracked innvim-pack-lock.json. - Custom lazy-loading:
lua/lazy.luais a ~35-line custom framework (unrelated to lazy.nvim). It providesload(),on_event(),on_keys(),on_cmd()and tracks loaded modules inM._loaded. - Mini.nvim monorepo: Most UI/functionality comes from the single
mini.nvimpackage. Its submodules (starter, pick, extra, files, icons, notify, cmdline, completion, snippets, surround, ai, cursorword, pairs) are configured individually inlua/pack.luaor on-demand.
File Loading Order
init.lua → disables ~20 built-in plugins, sets colorscheme, loads core modules
options.lua → global vim options, yank highlighting, fold settings
keymaps.lua → keymaps (leader = space)
autocmds.lua → cursor restore, comment continuation, fold setup
usercmds.lua → :PackAdd, :PackDel, :PackUpdate
pack.lua → plugin declarations + lazy-loading bindings
Plugin Commands
:PackAdd user/repo " add plugin
:PackDel plugin-name " delete plugin
:PackUpdate [name] " update all or specific plugin
:ExColors! " extract current colorscheme to optimized ex-colors
Validation & Debugging
# Syntax check init.lua (run from repo root)
nvim --headless -c 'lua dofile("init.lua")' -c 'qa!'
# Check a specific module
nvim --headless -c 'lua require("pack")' -c 'qa!'
# Health check
nvim --headless -c 'checkhealth' -c 'qa!'
# Measure startup time
nvim --startuptime /tmp/startup.log +q
There is no traditional lint, typecheck, or test command. The validation commands above are the only verification steps.
Lazy-Loading Strategy
When adding new plugins that should load lazily, use the custom framework in lua/lazy.lua — do not use lazy.nvim patterns.
| Trigger | Plugins / Modules |
|---|---|
VimEnter |
treesitter, lsp, icons |
InsertEnter |
completion, snippets, pairs |
BufReadPost |
gitsigns, surround, ai, cursorword |
BufWritePre |
conform (format-on-save) |
| Key press | pick, files, neogit, codediff, grugfar |
| Command | ex-colors (:ExColors) |
LSP & Formatting
- LSP servers enabled: html, cssls, gopls, vtsls, rust_analyzer, lua_ls, taplo, svelte, dartls, kotlin_lsp
- Lua LSP:
vimis declared as a global inlua_lssettings to suppress "Undefined global" diagnostics - Formatters by filetype:
lua→ styluago→ gofumpt, goimportsjs/ts/json/css/html/md→ biome (ifbiome.jsonfound) or prettiertoml→ taplo
- Toggle autoformat:
vim.b[bufnr].autoformat = false(buffer) orvim.g.autoformat = false(global)
Key Conventions
- Startup performance is a priority. Heavy modules are deferred to
VimEnteror later. Clipboard is set viavim.schedule()to avoid blocking. - The active colorscheme is
ex-catppuccin-mocha, defined incolors/ex-catppuccin-mocha.lua. - Comments and UI strings are in Chinese.