A seamless bridge between Claude Code CLI and Neovim that provides real-time file change synchronization, diff previews, and interactive change acceptance/rejection.
- Real-time Sync: See Claude Code's file changes instantly in Neovim (<100ms latency)
- Diff Preview: Visual floating windows showing exactly what changed
- Interactive Control: Accept or reject changes from within Neovim
- Change Indicators: Visual markers in the sign column for modified lines
- Auto-reload: Automatically refresh buffers when files change
- Non-intrusive: Works alongside your existing Neovim workflow
- Configurable: Customize behavior, appearance, and keybindings
- Cross-platform: Linux, macOS, and Windows (WSL) support
- Neovim 0.8.0+
- Python 3.8+
- Claude Code CLI (latest version)
git clone https://github.com/jkhas8/claude-code-nvim.git
cd claude-code-nvim
./install.shClick to expand manual installation steps
-
Clone the repository:
git clone https://github.com/jkhas8/claude-code-nvim.git cd claude-code-nvim -
Install Python dependencies:
cd file-watcher python3 -m venv venv source venv/bin/activate pip install -r requirements.txt
-
Install Neovim plugin:
For lazy.nvim:
{ "jkhas8/claude-code-nvim", config = function() require("claude-code-nvim").setup() end }For packer.nvim:
use { "jkhas8/claude-code-nvim", config = function() require("claude-code-nvim").setup() end }
For vim-plug:
Plug 'jkhas8/claude-code-nvim'
- Open Neovim in your project directory
- Press
<leader>Csor run:ClaudeCodeStart - Done! The plugin will guide you if the watcher isn't running
-
Start the file watcher:
# In your project directory claude-code-watch -
In Neovim, connect:
# Press <leader>Cs or run: :ClaudeCodeStart -
Use Claude Code as normal - changes appear instantly in Neovim!
<leader>Cr- Review pending changes<leader>Ca- Accept all changes<leader>Ct- Check connection status<leader>ww- Quick start (alternative binding)
Option A: System Service (Set-and-forget)
# Enable auto-start on login
systemctl --user enable claude-code-watcher
systemctl --user start claude-code-watcherOption B: Plugin Auto-start
require("claude-code-nvim").setup({
auto_start_watcher = true, -- Plugin tries to start watcher
auto_start = true, -- Auto-connect when Neovim opens
})| Command | Description |
|---|---|
:ClaudeCodeStart |
Connect to the file watcher |
:ClaudeCodeStop |
Disconnect from the file watcher |
:ClaudeCodeStatus |
Show connection and change status |
:ClaudeCodeReview |
Open the changes review window |
:ClaudeCodeAcceptAll |
Accept all pending changes |
:ClaudeCodeRejectAll |
Reject all pending changes |
Add to your init.lua:
require('claude-code-nvim').setup({
-- Connection settings
socket_path = '/tmp/claude-code-nvim.sock',
auto_start = true,
auto_reconnect = true,
-- UI settings
show_notifications = true,
show_statusline = true,
diff_preview = true,
-- Behavior
auto_accept = false, -- Set to true for automatic acceptance
auto_reload = true,
-- Appearance
icons = {
added = '+',
deleted = '-',
modified = '~',
pending = 'β',
connected = 'β',
disconnected = 'β'
},
-- Keymaps (in diff windows)
keymaps = {
accept = '<CR>',
reject = '<Esc>',
diff = 'd'
}
})βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β Claude Code βββββΆβ File System βββββΆβ File Watcher β
β CLI β β β β Service β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β
β IPC
βΌ
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β Neovim ββββββ Diff Preview ββββββ Neovim Plugin β
β Editor β β Window β β β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
- Claude Code modifies files
- File Watcher detects changes via filesystem events
- Neovim Plugin receives change notifications
- Diff Preview shows what changed
- You decide whether to accept or reject changes
- File Watcher (
file-watcher/watcher.py): Python service usingwatchdogfor filesystem monitoring - Neovim Plugin (
nvim-plugin/): Lua plugin for Neovim integration - IPC Communication: Unix sockets for fast, reliable communication
- Diff Engine: Line-by-line change detection and visualization
claude-code-nvim/
βββ file-watcher/ # Python file watcher service
β βββ watcher.py # Main watcher implementation
β βββ requirements.txt # Python dependencies
βββ nvim-plugin/ # Neovim plugin
β βββ lua/claude-code-nvim/
β β βββ init.lua # Main plugin entry
β β βββ config.lua # Configuration management
β β βββ ipc.lua # IPC communication
β β βββ events.lua # Event handling
β β βββ buffer.lua # Buffer management
β β βββ ui.lua # User interface
β βββ plugin/
β βββ claude-code-nvim.vim
βββ scripts/ # Installation and utility scripts
# Test the file watcher
cd file-watcher
python3 -m pytest tests/
# Test the Neovim plugin
nvim --headless -c "PlenaryBustedDirectory nvim-plugin/tests/ {minimal_init = 'nvim-plugin/tests/minimal_init.vim'}"- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Submit a pull request
MIT License - see LICENSE file for details.
- Ensure the file watcher is running:
ps aux | grep watcher.py - Check socket permissions:
ls -la /tmp/claude-code-nvim.sock - View logs:
tail -f ~/.local/share/claude-code-nvim/watcher.log
- Reduce
debounce_delayin configuration - Add more patterns to
ignore_patterns - Limit
watch_pathsto relevant directories
- Check Neovim version:
nvim --version(requires 0.8.0+) - Verify plugin installation path
- Check for conflicts with other plugins
Add to your status line configuration:
-- For lualine.nvim
sections = {
lualine_x = { 'claude_code_status' }
}
-- For vim-airline
let g:airline_section_x = airline#section#create(['claude_code_status'])The plugin uses these highlight groups:
DiffAdd: Added linesDiffDelete: Deleted linesDiffChange: Modified linesWarningMsg: Pending changes
Customize with:
vim.api.nvim_set_hl(0, 'ClaudeCodeAdded', { fg = '#00ff00' })