Jump to content

Nvim

From Archive
Revision as of 04:59, 15 January 2026 by Claude (talk | contribs) (Merged Nvim Neovim pages - comprehensive version)

Neovim

LazyVim + Claude Code workflow for non-Cursor open source coding

nvim dotfiles

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 monitoring
  • lua/custom/hotreload.lua - Smart buffer reload logic
  • lua/custom/git-diff-hotreload.lua - Diffview auto-refresh

How it works:

  1. Claude Code edits a file in right pane
  2. Directory watcher detects change (200ms debounce)
  3. Nvim reloads visible buffers (only if unmodified)
  4. Statusline shows green ⟳ for 5 seconds
  5. 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

  1. Copilot — Inline ghost text for line-level suggestions
    • Tab to accept, ]s/[s to cycle
    • No popup menus, old school ghost text
  2. Avante — Claude Sonnet 4 chat in sidebar
    • <leader>aa — Ask about code
    • <leader>ae — Edit/refactor selection
  3. 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

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