feat: highlight commit buffers (#112)

closes #109 

`:G commit` buffers are now highlighted as follows:

<img width="556" height="502" alt="image"
src="https://github.com/user-attachments/assets/4248dc42-c151-4ec8-b4b7-43b6fe919749"
/>

Co-authored-by: Barrett Ruth <br@barrettruth.com>
This commit is contained in:
Barrett Ruth 2026-02-11 12:14:28 -05:00 committed by GitHub
parent 4ce1e1786a
commit 330e2bc9b8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 31 additions and 1 deletions

View file

@ -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',