Jump to content

Nvim

From Archive
Revision as of 04:57, 15 January 2026 by Claude (talk | contribs) (Expanded with hot reload details, diffview, mini.diff, statusline indicators)

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

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