A Neovim plugin that automatically runs :checktime on visible buffers when they change on disk using efficient file system event watchers.
This is quite useful when working with cli based AI agents like claude code or aider since you can see the files changing in real time.
- Uses native file system event watchers (inotify/FSEvents/etc.) for instant, efficient reloading
- Only watches buffers that are currently visible in a window
- Automatically adds/removes watchers as buffers become visible/hidden
- Runs
:checktimewhen a buffer becomes visible or gets focus - Only checks unmodified buffers to avoid conflicts with your work
- Silent by default - no notifications when files are reloaded
- Optional polling fallback for compatibility
Using lazy.nvim:
{
'diogo464/hotreload.nvim',
opts = {} -- Uses fs_event watchers by default
}interval(number|nil): Optional polling interval in milliseconds. Default:nil(disabled)- When
nil, uses efficient fs_event watchers (recommended) - Set to a number (e.g.,
500) to enable polling fallback - Polling uses more CPU but may be more compatible in some environments
- When
silent(boolean): Suppress file reload notifications. Default:true- Set to
falseif you want to see notifications when files are reloaded
- Set to
log(table|nil): Configure logging. Default:nil(disabled)use_file(boolean): Write logs to a file. Default:falseuse_console(boolean): Echo logs to:messages. Default:falselevel(string): Minimum level to log. Default:"info"- Log file path:
stdpath("data")/hotreload.nvim/hotreload.nvim.log
If you experience issues with fs_event watchers, you can enable polling:
{
'diogo464/hotreload.nvim',
opts = {
interval = 500, -- Poll every 500ms
silent = true,
}
}{
'diogo464/hotreload.nvim',
opts = {
log = {
use_file = true,
level = "debug",
}
}
}The plugin uses Neovim's vim.uv.new_fs_event() API to watch visible buffer files for changes:
- When you open or switch to a buffer, the plugin creates a file system watcher for that file
- The watcher uses the OS's native notification system (inotify on Linux, FSEvents on macOS, etc.)
- When the file changes on disk, the watcher immediately triggers
:checktimeto reload the buffer - When you close or hide a buffer, the watcher is automatically removed to free resources
- Only unmodified buffers are reloaded to avoid overwriting your work
This approach is much more efficient than polling because:
- Zero CPU usage when files aren't changing
- Instant response to file changes (no polling delay)
- Scales to many open buffers without performance impact
Linux users: If you have many files open, you may need to increase the inotify watch limit:
# Temporarily increase limit
sudo sysctl fs.inotify.max_user_watches=524288
# Permanently increase limit
echo "fs.inotify.max_user_watches=524288" | sudo tee -a /etc/sysctl.conf
sudo sysctl -p