Nvim: Difference between revisions
Expanded with Claude Code workflow documentation |
Expanded with hot reload details, diffview, mini.diff, statusline indicators |
||
| 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 | ||
* | |||
''Triggers:'' | |||
* FocusGained, TermLeave (switching from Claude Code pane) | |||
* | * BufEnter, WinEnter (switching windows) | ||
* CursorHold (idle cursor) | |||
* Filesystem changes in project directory | |||
== | == Diffview Integration == | ||
Review all robot changes with one keystroke. | |||
''File:'' <code>lua/plugins/claude-code-workflow.lua</code> | |||
{| class="wikitable" | {| class="wikitable" | ||
| Line 44: | Line 59: | ||
! Key !! Action | ! Key !! Action | ||
|- | |- | ||
| <code> | | <code><leader>gd</code> || Open diffview (review all changes) | ||
|- | |- | ||
| <code> | | <code><leader>gh</code> || File history | ||
|- | |- | ||
| <code> | | <code><leader>gc</code> || Close diffview | ||
|- | |- | ||
| <code> | | <code>]c</code> / <code>[c</code> || Jump between changes | ||
|- | |- | ||
| <code> | | <code>Tab</code> || Cycle through files | ||
|} | |} | ||
'' | ''Auto-refresh:'' When Claude Code commits, diffview refreshes automatically via git-diff-hotreload watching <code>.git/</code> directory. | ||
== | == 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 | |||
|} | |||
Uses <code>▎</code> signs for additions/changes, clean minimal look. | |||
== Inline AI (Ghost Text) == | |||
''File:'' <code>lua/plugins/copilot-inline.lua</code> | |||
Ghost text suggestions, not popup completions: | |||
{| class="wikitable" | {| class="wikitable" | ||
| Line 73: | Line 99: | ||
! Key !! Action | ! Key !! Action | ||
|- | |- | ||
| <code>< | | <code>Tab</code> || Accept full suggestion | ||
|- | |||
| <code>]s</code> / <code>[s</code> || Cycle through suggestions | |||
|- | |- | ||
| <code> | | <code>C-Right</code> || Accept one word | ||
|- | |- | ||
| <code> | | <code>C-l</code> || Accept one line | ||
|- | |- | ||
| <code> | | <code>C-]</code> || Dismiss | ||
|} | |} | ||
''Why inline > popup:'' Ghost text for AI, completion menu for LSP. No fighting between them. | |||
== LSP & Formatting == | |||
''conform.nvim'' handles formatting with Prettier (respects project .prettierrc) | |||
''Statusline shows active LSPs:'' | |||
* Vue, TypeScript, ESLint, Python, Rust, Lua icons | |||
* Copilot filtered from display (but still active) | |||
''Diagnostics:'' Error/warning/hint counts in statusline (E/W/H format) | |||
== Yank With Context == | == Yank With Context == | ||
| Line 88: | Line 127: | ||
* <code><leader>ya</code> → Yank with absolute path | * <code><leader>ya</code> → Yank with absolute path | ||
Output: < | ''Output format:'' | ||
<pre> | |||
src/components/Button.tsx:15-23 | |||
```tsx | |||
import { useState } from 'react' | |||
// selected code here | |||
``` | |||
</pre> | |||
Claude Code sees exact file + line numbers = perfect context. | |||
== Statusline Indicators == | == Statusline Indicators == | ||
''File:'' <code>lua/plugins/minimal-statusline.lua</code> | |||
{| class="wikitable" | |||
|- | |||
! Symbol !! Color !! Meaning | |||
|- | |||
| <code>●</code> || Red || Unsaved changes | |||
|- | |||
| <code>⟳</code> || Green || Just reloaded by Claude Code (5 sec) | |||
|- | |||
| <code>AI</code> || Gray || Copilot attached | |||
|- | |||
| <code>Δ</code> || Blue || Diffview open | |||
|} | |||
Also shows: file path (last 2 dirs + filename), line count, diagnostics, LSP icons. | |||
== CLI Aliases == | == CLI Aliases == | ||
| Line 102: | Line 162: | ||
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 (sorted by recency) | ||
r # Recent files across ALL ~/code projects | r # Recent files across ALL ~/code projects | ||
tip # Random tip from ~/tips.txt | |||
</pre> | </pre> | ||
== | == Plugin Stack == | ||
''Core:'' | |||
* '''twilight | * LazyVim (base, most defaults disabled) | ||
* | * oil.nvim (filesystem as buffer) | ||
* telescope (fuzzy finding) | |||
* diffview + mini.diff (git visualization) | |||
* harpoon (quick file switching) | |||
''AI:'' | |||
* copilot.lua (ghost text) | |||
* Claude Code CLI (separate terminal) | |||
''Visual:'' | |||
* ayu theme (dark, easy on eyes) | |||
* twilight (dims inactive code) | |||
* zen-mode (distraction-free) | |||
''Workflow:'' | |||
* vim-tmux-navigator (seamless pane switching) | |||
* surround, hardtime, vimbegood | |||
== The Magic Moment == | |||
Robot edits 5 files → nvim shows green ⟳ → all files refresh → <code><leader>gd</code> → review everything in diffview → back to coding. | |||
No manual steps. Just flow. | |||
== See Also == | == See Also == | ||
| Line 115: | Line 197: | ||
* [[CLI]] | * [[CLI]] | ||
* [[VPS]] | * [[VPS]] | ||
* [[SSH]] | |||
[[Category:Technical]] | [[Category:Technical]] | ||
Revision as of 04:57, 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
Diffview Integration
Review all robot changes with one keystroke.
File: lua/plugins/claude-code-workflow.lua
| 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 via git-diff-hotreload watching .git/ directory.
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 |
Uses ▎ signs for additions/changes, clean minimal look.
Inline AI (Ghost Text)
File: lua/plugins/copilot-inline.lua
Ghost text suggestions, not popup completions:
| Key | Action |
|---|---|
Tab |
Accept full suggestion |
]s / [s |
Cycle through suggestions |
C-Right |
Accept one word |
C-l |
Accept one line |
C-] |
Dismiss |
Why inline > popup: Ghost text for AI, completion menu for LSP. No fighting between them.
LSP & Formatting
conform.nvim handles formatting with Prettier (respects project .prettierrc)
Statusline shows active LSPs:
- Vue, TypeScript, ESLint, Python, Rust, Lua icons
- Copilot filtered from display (but still active)
Diagnostics: Error/warning/hint counts in statusline (E/W/H format)
Yank With Context
Share code with Claude Code including file path:
<leader>yr→ Yank with relative path<leader>ya→ Yank with absolute path
Output format:
src/components/Button.tsx:15-23
```tsx
import { useState } from 'react'
// selected code here
```
Claude Code sees exact file + line numbers = perfect context.
Statusline Indicators
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.
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 (sorted by recency) r # Recent files across ALL ~/code projects tip # Random tip from ~/tips.txt
Plugin Stack
Core:
- LazyVim (base, most defaults disabled)
- oil.nvim (filesystem as buffer)
- telescope (fuzzy finding)
- diffview + mini.diff (git visualization)
- harpoon (quick file switching)
AI:
- copilot.lua (ghost text)
- Claude Code CLI (separate terminal)
Visual:
- ayu theme (dark, easy on eyes)
- twilight (dims inactive code)
- zen-mode (distraction-free)
Workflow:
- vim-tmux-navigator (seamless pane switching)
- surround, hardtime, vimbegood
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 |