Nvim: Difference between revisions
Expanded with hot reload details, diffview, mini.diff, statusline indicators |
Merged Nvim Neovim pages - comprehensive version |
||
| Line 49: | Line 49: | ||
* CursorHold (idle cursor) | * CursorHold (idle cursor) | ||
* Filesystem changes in project directory | * Filesystem changes in project directory | ||
== Three-Layer AI System == | |||
# ''Copilot'' — Inline ghost text for line-level suggestions | |||
#* Tab to accept, ]s/[s to cycle | |||
#* No popup menus, old school ghost text | |||
# ''Avante'' — Claude Sonnet 4 chat in sidebar | |||
#* <code><leader>aa</code> — Ask about code | |||
#* <code><leader>ae</code> — Edit/refactor selection | |||
# ''Claude Code'' — Full agent in tmux pane | |||
#* Hot reload integration | |||
#* Diffview for reviewing changes | |||
=== Copilot Keybindings === | |||
{| class="wikitable" | |||
|- | |||
! Key !! Action | |||
|- | |||
| <code>Tab</code> || Accept full suggestion | |||
|- | |||
| <code>]s</code> / <code>[s</code> || Cycle through suggestions | |||
|- | |||
| <code>C-Right</code> || Accept one word | |||
|- | |||
| <code>C-l</code> || Accept one line | |||
|- | |||
| <code>C-]</code> || Dismiss | |||
|} | |||
== Diffview Integration == | == Diffview Integration == | ||
Review all robot changes with one keystroke. | Review all robot changes with one keystroke. | ||
{| class="wikitable" | {| class="wikitable" | ||
| Line 70: | Line 96: | ||
|} | |} | ||
''Auto-refresh:'' When Claude Code commits, diffview refreshes automatically | ''Auto-refresh:'' When Claude Code commits, diffview refreshes automatically. | ||
== Inline Git Diff == | == Inline Git Diff == | ||
| Line 88: | Line 114: | ||
|} | |} | ||
== Statusline == | |||
''File:'' <code>lua/plugins/minimal-statusline.lua</code> | |||
== | |||
''File:'' <code>lua/plugins/ | |||
Shows only essential info: | |||
* Context path (2 parent dirs + filename) | |||
* Line count | |||
* Diagnostics (error/warn/hint counts) | |||
* LSP icons (TypeScript, Vue, ESLint, etc) | |||
{| class="wikitable" | {| class="wikitable" | ||
|- | |- | ||
! | ! Symbol !! Color !! Meaning | ||
|- | |- | ||
| <code> | | <code>●</code> || Red || Unsaved changes | ||
|- | |- | ||
| <code> | | <code>⟳</code> || Green || Just reloaded by Claude Code (5 sec) | ||
|- | |- | ||
| <code> | | <code>AI</code> || Gray || Copilot attached | ||
|- | |- | ||
| <code> | | <code>Δ</code> || Blue || Diffview open | ||
| | |||
| | |||
|} | |} | ||
== Yank With Context == | |||
Share code with Claude Code including file path: | |||
* <code><leader>yr</code> → Yank with relative path | |||
* <code><leader>ya</code> → Yank with absolute path | |||
''Output:'' <code>src/file.ts:42-55</code> with fenced code block | |||
'' | |||
== Essential Plugins == | |||
=== Navigation === | |||
== | ''Oil.nvim'' — Filesystem as a buffer | ||
<pre> | |||
- Open parent directory | |||
<CR> Open file/directory | |||
g. Toggle hidden files | |||
</pre> | |||
''Harpoon'' — Quick access to marked files | |||
<pre> | |||
<leader>ha Add file to harpoon | |||
<leader>hh Toggle harpoon menu | |||
<leader>h1-4 Jump to file 1-4 | |||
</pre> | |||
''vim-tmux-navigator'' — Seamless pane navigation | |||
<pre> | |||
Ctrl-h/j/k/l Move between nvim splits AND tmux panes | |||
</pre> | |||
=== Editing === | |||
''nvim-surround'' — Surround text objects | |||
<pre> | |||
ysiw" Wrap word in quotes | |||
cs"' Change " to ' | |||
ds" Delete surrounding quotes | |||
</pre> | |||
''Dial.nvim'' — Smart increment/decrement | |||
<pre> | |||
<C-a> on true → false | |||
<C-a> on 1 → 2 | |||
</pre> | |||
=== Focus === | |||
''Zen-mode'' — Distraction-free writing | |||
''Twilight'' — Dim inactive code blocks | |||
=== Git === | |||
''Gitsigns'' — Change indicators in sign column | |||
'' | ''Git-conflict'' — Visual merge conflict handling | ||
<pre> | <pre> | ||
co Choose ours | |||
ct Choose theirs | |||
cb Choose both | |||
/ | [x/]x Jump between conflicts | ||
</pre> | </pre> | ||
=== HTTP === | |||
''Kulala.nvim'' — HTTP client in buffer | |||
'' | <pre> | ||
<CR> Execute request under cursor | |||
[r / ]r Jump between requests | |||
</pre> | |||
== Training Mode == | |||
''Hardtime'' — Vim motion coaching: | |||
* Blocks hjkl spam after 1 press | |||
* Arrow keys disabled | |||
* Hints for better motions | |||
== CLI Aliases == | == CLI Aliases == | ||
| Line 162: | Line 221: | ||
vs # Fuzzy find files with bat preview | vs # Fuzzy find files with bat preview | ||
vg # Grep contents, fuzzy find, open file | vg # Grep contents, fuzzy find, open file | ||
o # Obsidian vault fuzzy finder | o # Obsidian vault fuzzy finder | ||
r # Recent files across ALL ~/code projects | r # Recent files across ALL ~/code projects | ||
</pre> | </pre> | ||
== | == File Structure == | ||
<pre> | |||
~/.config/nvim/ | |||
├── init.lua | |||
├── colors/ # Vulpes themes | |||
├── lua/ | |||
│ ├── plugins/ # Plugin specs | |||
│ │ ├── minimal-statusline.lua | |||
│ │ ├── claude-code-workflow.lua | |||
│ │ ├── copilot-inline.lua | |||
│ │ └── ... | |||
│ └── custom/ # Custom modules | |||
│ ├── hotreload.lua | |||
│ └── directory-watcher.lua | |||
└── CLAUDE-CODE-WORKFLOW.md | |||
</pre> | |||
== The Magic Moment == | == The Magic Moment == | ||
Revision as of 04:59, 15 January 2026
Neovim
LazyVim + Claude Code workflow for non-Cursor open source coding
Philosophy
Code manually in nvim (left pane) with subtle AI assistance, while Claude Code handles big refactors in a separate tmux pane (right). Robot edits files → nvim auto-reloads → review changes instantly.
┌─────────────────┬─────────────────┐ │ nvim (manual) │ Claude Code │ │ - Ghost text AI │ - Big refactors │ │ - Hot reload │ - File edits │ │ - Diffview │ - Commits │ └─────────────────┴─────────────────┘
Why not Cursor?
- Nvim muscle memory preserved
- Complete control over AI integration
- No vendor lock-in
- tmux + ssh workflow stays intact
- Works on remote servers seamlessly
- OSC52 clipboard works over SSH
Hot Reload System
The killer feature. When Claude Code edits files, nvim reloads them automatically.
Files:
lua/custom/directory-watcher.lua- Native fs_event monitoringlua/custom/hotreload.lua- Smart buffer reload logiclua/custom/git-diff-hotreload.lua- Diffview auto-refresh
How it works:
- Claude Code edits a file in right pane
- Directory watcher detects change (200ms debounce)
- Nvim reloads visible buffers (only if unmodified)
- Statusline shows green ⟳ for 5 seconds
- Notification: "📝 File reloaded (Claude Code edit)"
Safety:
- Never reloads modified buffers (won't lose unsaved work)
- Skips special buffers (neo-tree, diffview, terminals)
- Ignores .git/, node_modules/, swap files
Triggers:
- FocusGained, TermLeave (switching from Claude Code pane)
- BufEnter, WinEnter (switching windows)
- CursorHold (idle cursor)
- Filesystem changes in project directory
Three-Layer AI System
- Copilot — Inline ghost text for line-level suggestions
- Tab to accept, ]s/[s to cycle
- No popup menus, old school ghost text
- Avante — Claude Sonnet 4 chat in sidebar
<leader>aa— Ask about code<leader>ae— Edit/refactor selection
- Claude Code — Full agent in tmux pane
- Hot reload integration
- Diffview for reviewing changes
Copilot Keybindings
| Key | Action |
|---|---|
Tab |
Accept full suggestion |
]s / [s |
Cycle through suggestions |
C-Right |
Accept one word |
C-l |
Accept one line |
C-] |
Dismiss |
Diffview Integration
Review all robot changes with one keystroke.
| Key | Action |
|---|---|
<leader>gd |
Open diffview (review all changes) |
<leader>gh |
File history |
<leader>gc |
Close diffview |
]c / [c |
Jump between changes |
Tab |
Cycle through files |
Auto-refresh: When Claude Code commits, diffview refreshes automatically.
Inline Git Diff
Plugin: mini.diff - shows deleted lines inline
| Key | Action |
|---|---|
gh |
Apply hunk |
gH |
Reset hunk |
[h / ]h |
Navigate hunks |
<leader>go |
Toggle diff overlay |
Statusline
File: lua/plugins/minimal-statusline.lua
Shows only essential info:
- Context path (2 parent dirs + filename)
- Line count
- Diagnostics (error/warn/hint counts)
- LSP icons (TypeScript, Vue, ESLint, etc)
| Symbol | Color | Meaning |
|---|---|---|
● |
Red | Unsaved changes |
⟳ |
Green | Just reloaded by Claude Code (5 sec) |
AI |
Gray | Copilot attached |
Δ |
Blue | Diffview open |
Yank With Context
Share code with Claude Code including file path:
<leader>yr→ Yank with relative path<leader>ya→ Yank with absolute path
Output: src/file.ts:42-55 with fenced code block
Essential Plugins
Navigation
Oil.nvim — Filesystem as a buffer
- Open parent directory <CR> Open file/directory g. Toggle hidden files
Harpoon — Quick access to marked files
<leader>ha Add file to harpoon <leader>hh Toggle harpoon menu <leader>h1-4 Jump to file 1-4
vim-tmux-navigator — Seamless pane navigation
Ctrl-h/j/k/l Move between nvim splits AND tmux panes
Editing
nvim-surround — Surround text objects
ysiw" Wrap word in quotes cs"' Change " to ' ds" Delete surrounding quotes
Dial.nvim — Smart increment/decrement
<C-a> on true → false <C-a> on 1 → 2
Focus
Zen-mode — Distraction-free writing
Twilight — Dim inactive code blocks
Git
Gitsigns — Change indicators in sign column
Git-conflict — Visual merge conflict handling
co Choose ours ct Choose theirs cb Choose both [x/]x Jump between conflicts
HTTP
Kulala.nvim — HTTP client in buffer
<CR> Execute request under cursor [r / ]r Jump between requests
Training Mode
Hardtime — Vim motion coaching:
- Blocks hjkl spam after 1 press
- Arrow keys disabled
- Hints for better motions
CLI Aliases
v # Just nvim n # nvim . (open with oil.nvim) vs # Fuzzy find files with bat preview vg # Grep contents, fuzzy find, open file o # Obsidian vault fuzzy finder r # Recent files across ALL ~/code projects
File Structure
~/.config/nvim/ ├── init.lua ├── colors/ # Vulpes themes ├── lua/ │ ├── plugins/ # Plugin specs │ │ ├── minimal-statusline.lua │ │ ├── claude-code-workflow.lua │ │ ├── copilot-inline.lua │ │ └── ... │ └── custom/ # Custom modules │ ├── hotreload.lua │ └── directory-watcher.lua └── CLAUDE-CODE-WORKFLOW.md
The Magic Moment
Robot edits 5 files → nvim shows green ⟳ → all files refresh → <leader>gd → review everything in diffview → back to coding.
No manual steps. Just flow.
See Also
| ⚡ Technical | |
|---|---|
| Core | Technical · CLI · Dotfiles · Nvim · SSH · VPS |
| Tools | Sketchybar · ArchiveBox · ThinkPad Linux |
| Systems | Automation · Personal APIs · Quantified Self |
| Reference | Runbooks · New Computer Runbook · Syntax guide |