1
0
Fork
You've already forked autoread-diff.nvim
0
Show differences when a file is reloaded after being modified externally
  • Lua 100%
2026年07月05日 07:53:28 +02:00
doc custom hl groups so they can be overridden, improve docs 2026年07月04日 13:35:45 +02:00
lua guard nvim_buf_set_extmark calls 2026年07月05日 07:53:28 +02:00
plugin default timeout to 0, document max_bytes option 2026年07月04日 10:26:12 +02:00
LICENSE add license 2026年06月29日 10:32:50 +02:00
README.md custom hl groups so they can be overridden, improve docs 2026年07月04日 13:35:45 +02:00

autoread-diff

Show changes when a file is reloaded after being modified externally.

Screenshot

The diff will be cleared when entering insert mode or when the buffer is modified.

To manually clear the diff you can use :AutoreadDiffClear.

This is not meant for full diff viewing, there are better options for that. This is for highlighting external changes to a file you're editing, for example when running a formatter, so only the new text (and the old deleted) is shown.

Options

A timeout can be set for automatically clearing the diff:

vim.g.autoread_diff_highlight_ms = 5000

When a timeout is set the diff will also be cleared on cursor movement.

Because of a Neovim limitation, the plugin holds a copy of every opened buffer, so to reduce memory impact it disables itself for files larger than 1MB.

This limit can be changed:

vim.g.autoread_diff_max_bytes = 5 * 1024 * 1024

Highlights

The highlight groups used are AudoreadDiffAdd, AutoreadDiffText, and AutoreadDiffDelete. By default they are linked to DiffAdd, DiffText, and DiffDelete, but you or your color scheme can override them.

Install

To install and load the plugin just add this:

vim.pack.add({"https://codeberg.org/micampe/autoread-diff.nvim"})

You don't need to call a setup function, the plugin is already set up to be loaded on demand.