Nvim: Difference between revisions
Expanded with Claude Code workflow documentation |
Add LazyVim quick reference tables for splits, buffers, navigation |
||
| (3 intermediate revisions by the same user not shown) | |||
| Line 16: | Line 16: | ||
</pre> | </pre> | ||
''Why not Cursor?'' | |||
* Nvim muscle memory preserved | * Nvim muscle memory preserved | ||
* Complete control over AI integration | * Complete control over AI integration | ||
* No vendor lock-in | * No vendor lock-in | ||
* tmux + ssh workflow stays intact | * tmux + ssh workflow stays intact | ||
* Works on remote servers | * 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:'' | |||
* <code>lua/custom/directory-watcher.lua</code> - Native fs_event monitoring | |||
* <code>lua/custom/hotreload.lua</code> - Smart buffer reload logic | |||
* <code>lua/custom/git-diff-hotreload.lua</code> - 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 | ||
* | |||
== | == Lazygit Integration == | ||
''Critical to the workflow.'' Lazygit is the bridge between reviewing Claude's changes and committing them. | |||
''Access from anywhere:'' | |||
'' | * <code><leader>gg</code> — Open lazygit in floating tmux popup (snacks.nvim) | ||
* Works from any nvim buffer, any tmux pane | |||
* Full-screen TUI for staging, committing, branching | |||
''Why lazygit matters:'' | |||
* Claude Code makes changes → you review in diffview → stage/commit in lazygit | |||
* Interactive staging: pick exactly which hunks to commit | |||
* Amend commits, rebase, cherry-pick - all without leaving the terminal | |||
* Visual branch management | |||
* Integrates with delta for beautiful diffs | |||
''Flow:'' | |||
# Claude edits files | |||
# <code><leader>gd</code> to review in diffview | |||
# <code><leader>gg</code> to open lazygit | |||
# Stage changes (space), write commit message, commit (c-c) | |||
# Back to coding | |||
== Diffview Integration == | |||
Review all robot changes with one keystroke. | |||
{| class="wikitable" | |||
|- | |||
! Key !! Action | |||
|- | |||
| <code><leader>gd</code> || Open diffview (review all changes) | |||
|- | |||
| <code><leader>gh</code> || File history | |||
|- | |||
| <code><leader>gc</code> || Close diffview | |||
|- | |||
| <code>]c</code> / <code>[c</code> || Jump between changes | |||
|- | |||
| <code>Tab</code> || Cycle through files | |||
|} | |||
''Auto-refresh:'' When Claude Code commits, diffview refreshes automatically. | |||
== 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" | {| class="wikitable" | ||
|- | |- | ||
| Line 55: | Line 114: | ||
|} | |} | ||
'' | == Inline Git Diff == | ||
''Plugin:'' mini.diff - shows deleted lines inline | |||
= | {| class="wikitable" | ||
|- | |||
! Key !! Action | |||
|- | |||
| <code>gh</code> || Apply hunk | |||
|- | |||
| <code>gH</code> || Reset hunk | |||
|- | |||
| <code>[h</code> / <code>]h</code> || Navigate hunks | |||
|- | |||
| <code><leader>go</code> || Toggle diff overlay | |||
|} | |||
== Statusline == | |||
''File:'' <code>lua/plugins/minimal-statusline.lua</code> | |||
== | |||
''File: <code> | |||
{| 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 | ||
|} | |} | ||
Also shows: file path (last 2 dirs + filename), line count, diagnostics, LSP icons. | |||
== Yank With Context == | == Yank With Context == | ||
| Line 88: | Line 154: | ||
* <code><leader>ya</code> → Yank with absolute path | * <code><leader>ya</code> → Yank with absolute path | ||
Output: <code>src/ | ''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> | |||
=== Git === | |||
''Lazygit'' — Full git TUI (see above) | |||
<pre> | |||
<leader>gg Open lazygit popup | |||
</pre> | |||
''Gitsigns'' — Change indicators in sign column | |||
''Git-conflict'' — Visual merge conflict handling | |||
<pre> | |||
co Choose ours | |||
ct Choose theirs | |||
cb Choose both | |||
[x/]x Jump between conflicts | |||
</pre> | |||
=== Editing === | |||
''nvim-surround'' — Surround text objects | |||
<pre> | |||
ysiw" Wrap word in quotes | |||
cs"' Change " to ' | |||
ds" Delete surrounding quotes | |||
</pre> | |||
=== Focus === | |||
''Zen-mode'' — Distraction-free writing | |||
''Twilight'' — Dim inactive code blocks | |||
* | == Training Mode == | ||
''Hardtime'' — Vim motion coaching: | |||
* Blocks hjkl spam after 1 press | |||
* Arrow keys disabled | |||
* Hints for better motions | |||
== CLI Aliases == | == CLI Aliases == | ||
| Line 106: | Line 228: | ||
</pre> | </pre> | ||
== | == The Complete Flow == | ||
# Write code in nvim (left pane) | |||
# Claude Code refactors in right pane | |||
# Files auto-reload, statusline shows ⟳ | |||
# <code><leader>gd</code> — review changes in diffview | |||
# <code><leader>gg</code> — open lazygit, stage & commit | |||
# Back to coding | |||
''No context switching. No mouse. No leaving the terminal.'' | |||
== LazyVim Quick Reference == | |||
''Mental model: Windows are viewports (where you look), buffers are files in memory (what you're editing).'' | |||
=== Windows & Splits === | |||
{| class="wikitable" | |||
|- | |||
! Key !! Action !! Notes | |||
|- | |||
| <code><leader>-</code> || Split below || Stack two views | |||
|- | |||
| <code><leader>|</code> || Split right || Vertical split | |||
|- | |||
| <code><leader>wd</code> || Close current split || Keeps buffers alive | |||
|- | |||
| <code><leader>wm</code> || Zoom/maximize split || tmux-zoom vibe, toggle back | |||
|- | |||
| <code>Ctrl</code> + arrows || Resize split || Fast pane resizing | |||
|- | |||
| <code>Ctrl-w x</code> || Swap windows || When you like buffers but hate layout | |||
|- | |||
| <code>Ctrl-w o</code> || Close all other windows || Keep only current view | |||
|} | |||
=== Buffers === | |||
{| class="wikitable" | |||
|- | |||
! Key !! Action !! Notes | |||
|- | |||
| <code>Shift-h</code> / <code>Shift-l</code> || Prev/next buffer || Two-file ping-pong | |||
|- | |||
| <code><leader>bb</code> || Toggle other buffer || Flip between last two | |||
|- | |||
| <code><leader>,</code> || Buffer picker || When you have too many open | |||
|- | |||
| <code><leader>bo</code> || Delete other buffers || Clear mental clutter | |||
|- | |||
| <code><leader>bD</code> || Delete buffer AND window || Gone from everywhere | |||
|- | |||
| <code><leader>bp</code> / <code><leader>bP</code> || Pin buffer / nuke non-pinned || Keep active files sacred | |||
|- | |||
| <code><leader>bl</code> / <code><leader>br</code> || Delete buffers left/right || Brutal tabline cleanup | |||
|} | |||
=== Fast Navigation === | |||
{| class="wikitable" | |||
|- | |||
! Key !! Action !! Notes | |||
|- | |||
| <code><leader><space></code> || Find files || Open file without knowing path | |||
|- | |||
| <code><leader>fr</code> || Recent files || "I was just there" time machine | |||
|- | |||
| <code><leader>/</code> || Grep project || Find text across repo | |||
|- | |||
| <code><leader>sB</code> || Grep open buffers only || Search files you already have open | |||
|- | |||
| <code><leader>ss</code> || Jump to symbol in file || Go to function/section instantly | |||
|- | |||
| <code><leader>sk</code> || Search your keymaps || Meta: look up bindings | |||
|} | |||
== See Also == | == See Also == | ||
| Line 115: | Line 308: | ||
* [[CLI]] | * [[CLI]] | ||
* [[VPS]] | * [[VPS]] | ||
* [[SSH]] | |||
[[Category:Technical]] | [[Category:Technical]] | ||
Latest revision as of 14:00, 18 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
Lazygit Integration
Critical to the workflow. Lazygit is the bridge between reviewing Claude's changes and committing them.
Access from anywhere:
<leader>gg— Open lazygit in floating tmux popup (snacks.nvim)- Works from any nvim buffer, any tmux pane
- Full-screen TUI for staging, committing, branching
Why lazygit matters:
- Claude Code makes changes → you review in diffview → stage/commit in lazygit
- Interactive staging: pick exactly which hunks to commit
- Amend commits, rebase, cherry-pick - all without leaving the terminal
- Visual branch management
- Integrates with delta for beautiful diffs
Flow:
- Claude edits files
<leader>gdto review in diffview<leader>ggto open lazygit- Stage changes (space), write commit message, commit (c-c)
- Back to coding
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.
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 |
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
| Symbol | Color | Meaning |
|---|---|---|
● |
Red | Unsaved changes |
⟳ |
Green | Just reloaded by Claude Code (5 sec) |
AI |
Gray | Copilot attached |
Δ |
Blue | Diffview open |
Also shows: file path (last 2 dirs + filename), line count, diagnostics, LSP icons.
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
Git
Lazygit — Full git TUI (see above)
<leader>gg Open lazygit popup
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
Editing
nvim-surround — Surround text objects
ysiw" Wrap word in quotes cs"' Change " to ' ds" Delete surrounding quotes
Focus
Zen-mode — Distraction-free writing
Twilight — Dim inactive code blocks
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
The Complete Flow
- Write code in nvim (left pane)
- Claude Code refactors in right pane
- Files auto-reload, statusline shows ⟳
<leader>gd— review changes in diffview<leader>gg— open lazygit, stage & commit- Back to coding
No context switching. No mouse. No leaving the terminal.
LazyVim Quick Reference
Mental model: Windows are viewports (where you look), buffers are files in memory (what you're editing).
Windows & Splits
| Key | Action | Notes |
|---|---|---|
<leader>- |
Split below | Stack two views |
| Split right | Vertical split | |
<leader>wd |
Close current split | Keeps buffers alive |
<leader>wm |
Zoom/maximize split | tmux-zoom vibe, toggle back |
Ctrl + arrows |
Resize split | Fast pane resizing |
Ctrl-w x |
Swap windows | When you like buffers but hate layout |
Ctrl-w o |
Close all other windows | Keep only current view |
Buffers
| Key | Action | Notes |
|---|---|---|
Shift-h / Shift-l |
Prev/next buffer | Two-file ping-pong |
<leader>bb |
Toggle other buffer | Flip between last two |
<leader>, |
Buffer picker | When you have too many open |
<leader>bo |
Delete other buffers | Clear mental clutter |
<leader>bD |
Delete buffer AND window | Gone from everywhere |
<leader>bp / <leader>bP |
Pin buffer / nuke non-pinned | Keep active files sacred |
<leader>bl / <leader>br |
Delete buffers left/right | Brutal tabline cleanup |
Fast Navigation
| Key | Action | Notes |
|---|---|---|
<leader><space> |
Find files | Open file without knowing path |
<leader>fr |
Recent files | "I was just there" time machine |
<leader>/ |
Grep project | Find text across repo |
<leader>sB |
Grep open buffers only | Search files you already have open |
<leader>ss |
Jump to symbol in file | Go to function/section instantly |
<leader>sk |
Search your keymaps | Meta: look up bindings |
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 |