feat: set bufname for commit buffers

This commit is contained in:
Lewis Russell 2024-06-21 13:24:22 +01:00
parent 93c38d9726
commit e4efe9b99b
2 changed files with 7 additions and 2 deletions

View file

@ -187,7 +187,8 @@ local show_commit = async.create(3, function(win, open, bcache)
local sha = bcache.blame[cursor].commit.sha
local res = bcache.git_obj:command({ 'show', sha })
async.scheduler()
local commit_buf = api.nvim_create_buf(false, true)
local commit_buf = api.nvim_create_buf(true, true)
api.nvim_buf_set_name(commit_buf, bcache:get_rev_bufname(sha, true))
api.nvim_buf_set_lines(commit_buf, 0, -1, false, res)
vim.cmd[open]({ mods = { keepalt = true } })
api.nvim_win_set_buf(0, commit_buf)
@ -273,6 +274,7 @@ M.blame = function()
local blm_bo = vim.bo[blm_bufnr]
blm_bo.buftype = 'nofile'
blm_bo.bufhidden = 'wipe'
blm_bo.modifiable = false
blm_bo.filetype = 'gitsigns.blame'

View file

@ -22,8 +22,11 @@ local M = {
--- @field blame? table<integer,Gitsigns.BlameInfo?>
local CacheEntry = M.CacheEntry
function CacheEntry:get_rev_bufname(rev)
function CacheEntry:get_rev_bufname(rev, nofile)
rev = rev or self.git_obj.revision or ':0'
if nofile then
return string.format('gitsigns://%s/%s', self.git_obj.repo.gitdir, rev)
end
return string.format('gitsigns://%s/%s:%s', self.git_obj.repo.gitdir, rev, self.git_obj.relpath)
end