Skip to content

micampe/autoread-diff.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

Show differences when a file is reloaded after being modified externally

Topics

Resources

License

Stars

1 star

Watchers

0 watching

Forks

Releases

No releases published

Contributors

Languages