From 330e2bc9b89ebcc52b77a9fa960541c0cfbca81d Mon Sep 17 00:00:00 2001 From: Barrett Ruth <62671086+barrettruth@users.noreply.github.com> Date: Wed, 11 Feb 2026 12:14:28 -0500 Subject: [PATCH] feat: highlight commit buffers (#112) closes #109 `:G commit` buffers are now highlighted as follows: image Co-authored-by: Barrett Ruth --- plugin/diffs.lua | 2 +- spec/parser_spec.lua | 30 ++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/plugin/diffs.lua b/plugin/diffs.lua index face556..794e41a 100644 --- a/plugin/diffs.lua +++ b/plugin/diffs.lua @@ -6,7 +6,7 @@ vim.g.loaded_diffs = 1 require('diffs.commands').setup() vim.api.nvim_create_autocmd('FileType', { - pattern = { 'fugitive', 'git' }, + pattern = { 'fugitive', 'git', 'gitcommit' }, callback = function(args) local diffs = require('diffs') if args.match == 'git' and not diffs.is_fugitive_buffer(args.buf) then diff --git a/spec/parser_spec.lua b/spec/parser_spec.lua index d88f9b7..401948b 100644 --- a/spec/parser_spec.lua +++ b/spec/parser_spec.lua @@ -542,6 +542,36 @@ describe('parser', function() delete_buffer(bufnr) end) + it('parses diff from gitcommit verbose buffer', function() + local bufnr = create_buffer({ + '', + '# Please enter the commit message for your changes.', + '#', + '# On branch main', + '# Changes to be committed:', + '#\tmodified: test.lua', + '#', + '# ------------------------ >8 ------------------------', + '# Do not modify or remove the line above.', + 'diff --git a/test.lua b/test.lua', + 'index abc1234..def5678 100644', + '--- a/test.lua', + '+++ b/test.lua', + '@@ -1,3 +1,3 @@', + ' local function hello()', + '- print("hello world")', + '+ print("hello universe")', + ' return true', + }) + local hunks = parser.parse_buffer(bufnr) + + assert.are.equal(1, #hunks) + assert.are.equal('test.lua', hunks[1].filename) + assert.are.equal('lua', hunks[1].ft) + assert.are.equal(4, #hunks[1].lines) + delete_buffer(bufnr) + end) + it('stores repo_root on hunk when available', function() local bufnr = create_buffer({ 'M lua/test.lua',