feat: add support for diff and other filetypes

This commit is contained in:
Barrett Ruth 2026-02-12 18:04:47 -05:00
parent 9a0b812f69
commit 3990014a93
Signed by: barrett
GPG key ID: A6C96C9349D2FC81
4 changed files with 40 additions and 4 deletions

View file

@ -53,6 +53,7 @@ Configuration is done via `vim.g.diffs`. Set this before the plugin loads:
vim.g.diffs = {
debug = false,
hide_prefix = false,
filetypes = { 'fugitive', 'git', 'gitcommit' },
highlights = {
background = true,
gutter = true,
@ -115,6 +116,17 @@ Configuration is done via `vim.g.diffs`. Set this before the plugin loads:
is also enabled, the overlay inherits the line's
background color.
{filetypes} (table, default: {'fugitive','git','gitcommit'})
List of filetypes that trigger attachment. Add
`'diff'` to enable highlighting in plain `.diff`
and `.patch` files: >lua
vim.g.diffs = {
filetypes = {
'fugitive', 'git', 'gitcommit', 'diff',
},
}
<
{highlights} (table, default: see below)
Controls which highlight features are enabled.
See |diffs.Highlights| for fields.
@ -588,8 +600,8 @@ refresh({bufnr}) *diffs.refresh()*
IMPLEMENTATION *diffs-implementation*
Summary / commit detail views: ~
1. `FileType fugitive` or `FileType git` (for `fugitive://` buffers)
triggers |diffs.attach()|
1. `FileType` autocmd for configured filetypes (see {filetypes}) triggers
|diffs.attach()|. For `git` buffers, only `fugitive://` URIs are attached.
2. The buffer is parsed to detect file headers (`M path/to/file`,
`diff --git a/... b/...`) and hunk headers (`@@ -10,3 +10,4 @@`)
3. For each hunk: