Skip to content

Commit a6ff6da

Browse files
Anup SebastianAnup Sebastian
authored andcommitted
feat: reorg initial commit
1 parent 1f2f824 commit a6ff6da

File tree

2 files changed

+545
-0
lines changed

2 files changed

+545
-0
lines changed

MIGRATION.md

Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
# Migration Checklist - Neovim Config Refactor
2+
3+
## Current State ✅
4+
- [x] Working Python LSP (pyright)
5+
- [x] Working Flutter LSP (dartls)
6+
- [x] Lazy-loaded language profiles
7+
- [x] Common plugins loaded globally
8+
- [x] ~1200 line init.lua (needs refactoring)
9+
10+
## Phase 1: Understand Your Config (Before Refactoring)
11+
- [ ] Read through entire `init.lua` - understand every line
12+
- [ ] List all plugins you actually use (vs installed)
13+
- [ ] Identify startup bottlenecks: `nvim --startuptime startup.log`
14+
- [ ] Document your most-used keybindings
15+
- [ ] Run `:checkhealth` to verify everything works
16+
17+
## Phase 2: Extract Configuration (Low Risk)
18+
- [ ] Create `lua/config/options.lua` - Move all `vim.opt` settings
19+
- [ ] Create `lua/config/keymaps.lua` - Move global keymaps
20+
- [ ] Create `lua/config/autocmds.lua` - Move global autocmds
21+
- [ ] Update `init.lua` to require these modules
22+
- [ ] Test: Restart nvim, verify everything works
23+
24+
## Phase 3: Reorganize Plugins (Medium Risk)
25+
- [ ] Create `lua/plugins/core/` directory structure
26+
- [ ] Move UI plugins to `core/ui.lua`
27+
- [ ] Move editor plugins to `core/editor.lua`
28+
- [ ] Move git plugins to `core/git.lua`
29+
- [ ] Move completion to `core/completion.lua`
30+
- [ ] Test after EACH move - don't batch them!
31+
32+
## Phase 4: Refactor LSP (High Risk - Do Last!)
33+
- [ ] Create `lua/plugins/lsp/init.lua` for mason setup
34+
- [ ] Create `lua/plugins/lsp/servers.lua` for general servers (lua_ls)
35+
- [ ] Move language-specific LSP to their lang files
36+
- [ ] Create `lua/util/lsp.lua` for shared utilities
37+
- [ ] Test each language: Python, Flutter, Svelte
38+
39+
## Phase 5: Cleanup
40+
- [ ] Remove unused plugins (check with `:Lazy`)
41+
- [ ] Remove duplicate code
42+
- [ ] Add comments explaining WHY, not WHAT
43+
- [ ] Update README.md with your structure
44+
- [ ] Profile startup time - compare before/after
45+
46+
## Testing Checklist (Run After Each Phase)
47+
- [ ] Python: Open .py file, verify pyright loads, test completion
48+
- [ ] Flutter: Open .dart file, verify dartls loads, test completion
49+
- [ ] Svelte: Open .svelte file, verify svelte-ls loads
50+
- [ ] Git: Open a git repo, test gitsigns
51+
- [ ] Telescope: Test fuzzy finding (<leader>sf)
52+
- [ ] LSP: Test go-to-definition, hover, rename
53+
- [ ] Formatting: Test format-on-save
54+
- [ ] Sessions: Test session save/restore
55+
56+
## Rollback Plan
57+
```bash
58+
# Before starting, create a backup branch
59+
cd ~/.config/nvim
60+
git checkout -b refactor-backup
61+
git checkout -b refactor-attempt
62+
63+
# If something breaks:
64+
git checkout refactor-backup
65+
```
66+
67+
## Performance Targets
68+
| Metric | Before | Target | After |
69+
|--------|--------|--------|-------|
70+
| Startup time | ? ms | <100ms | ? ms |
71+
| Plugins loaded on startup | ? | <30 | ? |
72+
| Time to first edit | ? ms | <200ms | ? ms |
73+
74+
Measure with:
75+
```bash
76+
nvim --startuptime startup.log
77+
# Check the last line for total time
78+
```
79+
80+
## When NOT to Refactor
81+
- [ ] You don't understand why your current config works
82+
- [ ] You're in the middle of a project deadline
83+
- [ ] Your startup time is already <50ms
84+
- [ ] You haven't backed up your config
85+
86+
## When TO Refactor
87+
- [x] Your init.lua is >500 lines (yours is 1200!)
88+
- [x] You have duplicate code across files
89+
- [x] You're adding a 4th+ language (you have 3)
90+
- [x] Startup time is >200ms
91+
- [x] You want to understand how Neovim works
92+
93+
## Expected Benefits
94+
- Faster startup (lazy-loading)
95+
- Easier to add new languages (template)
96+
- Easier to debug (modular)
97+
- Easier to share/document
98+
- Better understanding of Neovim
99+
100+
## Expected Challenges
101+
- LSP loading timing issues (we already solved this!)
102+
- Plugin dependency conflicts
103+
- Breaking changes in lazy.nvim API
104+
- Time investment (plan 4-6 hours)
105+
106+
---
107+
108+
## Quick Win: Do This First (30 minutes)
109+
110+
1. **Extract options** (lowest risk, immediate clarity):
111+
```lua
112+
-- lua/config/options.lua
113+
vim.g.mapleader = ' '
114+
vim.g.maplocalleader = ' '
115+
vim.g.have_nerd_font = true
116+
vim.opt.number = true
117+
vim.opt.relativenumber = true
118+
-- ... all your vim.opt settings
119+
```
120+
121+
2. **Extract keymaps**:
122+
```lua
123+
-- lua/config/keymaps.lua
124+
-- Escape closes floating windows
125+
vim.keymap.set('n', '<Esc>', function()
126+
-- ... your escape logic
127+
end)
128+
```
129+
130+
3. **Update init.lua**:
131+
```lua
132+
-- NEW init.lua (first 3 lines!)
133+
require('config.options')
134+
require('config.keymaps')
135+
-- ... rest stays the same for now
136+
```
137+
138+
This alone will make your init.lua 200 lines shorter and much clearer!
139+
140+
---
141+
142+
## Resources to Keep Handy
143+
- [Lazy.nvim Spec](https://lazy.folke.io/spec)
144+
- [:help lua-guide](https://neovim.io/doc/user/lua-guide.html)
145+
- [Your ORGANIZATION.md](./ORGANIZATION.md)
146+
- [Kickstart.nvim](https://github.com/nvim-lua/kickstart.nvim) (reference only)
147+
148+
---
149+
150+
**Remember:** Refactoring is optional. Your current setup WORKS. Only refactor if:
151+
1. You want to learn more about Neovim
152+
2. You want to add many more languages
153+
3. Your startup time bothers you
154+
4. You enjoy organizing code
155+
156+
Good luck! 🚀

0 commit comments

Comments
 (0)