parent
354d4de02d
commit
4313a1f9c2
|
@ -975,10 +975,13 @@ a short commit hash. `g:gitsigns_head` returns the current HEAD for the
|
|||
current working directory, whereas `b:gitsigns_head` returns the current HEAD
|
||||
for each buffer.
|
||||
|
||||
*b:gitsigns_blame_line_dict*
|
||||
If |gitsigns-config-current_line_blame| is enabled, then contains dictionary
|
||||
of the blame object for current line. For complete list of keys, see the
|
||||
{blame_info} argument from |gitsigns-config-current_line_blame_formatter|.
|
||||
*b:gitsigns_blame_line* *b:gitsigns_blame_line_dict*
|
||||
Provided if |gitsigns-config-current_line_blame| is enabled.
|
||||
`b:gitsigns_blame_line` if formatted using
|
||||
`config.current_line_blame_formatter`. `b:gitsigns_blame_line_dict` is a
|
||||
dictionary containing of the blame object for the current line. For complete
|
||||
list of keys, see the {blame_info} argument from
|
||||
|gitsigns-config-current_line_blame_formatter|.
|
||||
|
||||
==============================================================================
|
||||
TEXT OBJECTS *gitsigns-textobject*
|
||||
|
|
|
@ -132,10 +132,13 @@ a short commit hash. `g:gitsigns_head` returns the current HEAD for the
|
|||
current working directory, whereas `b:gitsigns_head` returns the current HEAD
|
||||
for each buffer.
|
||||
|
||||
*b:gitsigns_blame_line_dict*
|
||||
If |gitsigns-config-current_line_blame| is enabled, then contains dictionary
|
||||
of the blame object for current line. For complete list of keys, see the
|
||||
{blame_info} argument from |gitsigns-config-current_line_blame_formatter|.
|
||||
*b:gitsigns_blame_line* *b:gitsigns_blame_line_dict*
|
||||
Provided if |gitsigns-config-current_line_blame| is enabled.
|
||||
`b:gitsigns_blame_line` if formatted using
|
||||
`config.current_line_blame_formatter`. `b:gitsigns_blame_line_dict` is a
|
||||
dictionary containing of the blame object for the current line. For complete
|
||||
list of keys, see the {blame_info} argument from
|
||||
|gitsigns-config-current_line_blame_formatter|.
|
||||
|
||||
==============================================================================
|
||||
TEXT OBJECTS *gitsigns-textobject*
|
||||
|
|
|
@ -37,7 +37,7 @@ local function get_extmark(bufnr)
|
|||
return
|
||||
end
|
||||
|
||||
local reset = function(bufnr)
|
||||
local function reset(bufnr)
|
||||
bufnr = bufnr or current_buf()
|
||||
api.nvim_buf_del_extmark(bufnr, namespace, 1)
|
||||
vim.b[bufnr].gitsigns_blame_line_dict = nil
|
||||
|
@ -85,6 +85,14 @@ local function expand_blame_format(fmt, name, info)
|
|||
return util.expand_format(fmt, info, config.current_line_blame_formatter_opts.relative_time)
|
||||
end
|
||||
|
||||
local function flatten_virt_text(virt_text)
|
||||
local res = {}
|
||||
for _, part in ipairs(virt_text) do
|
||||
res[#res + 1] = part[1]
|
||||
end
|
||||
return table.concat(res)
|
||||
end
|
||||
|
||||
|
||||
local update = void(function()
|
||||
local bufnr = current_buf()
|
||||
|
@ -147,7 +155,7 @@ local update = void(function()
|
|||
|
||||
vim.b[bufnr].gitsigns_blame_line_dict = result
|
||||
|
||||
if opts.virt_text and result then
|
||||
if result then
|
||||
local virt_text
|
||||
local clb_formatter = result.author == 'Not Committed Yet' and
|
||||
config.current_line_blame_formatter_nc or
|
||||
|
@ -165,6 +173,9 @@ local update = void(function()
|
|||
|
||||
end
|
||||
|
||||
vim.b[bufnr].gitsigns_blame_line = flatten_virt_text(virt_text)
|
||||
|
||||
if opts.virt_text then
|
||||
set_extmark(bufnr, lnum, {
|
||||
virt_text = virt_text,
|
||||
virt_text_pos = opts.virt_text_pos,
|
||||
|
@ -172,6 +183,7 @@ local update = void(function()
|
|||
hl_mode = 'combine',
|
||||
})
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
M.setup = function()
|
||||
|
|
|
@ -37,7 +37,7 @@ local function get_extmark(bufnr: integer): integer
|
|||
return
|
||||
end
|
||||
|
||||
local reset = function(bufnr: integer)
|
||||
local function reset(bufnr: integer)
|
||||
bufnr = bufnr or current_buf()
|
||||
api.nvim_buf_del_extmark(bufnr, namespace, 1)
|
||||
vim.b[bufnr].gitsigns_blame_line_dict = nil
|
||||
|
@ -85,6 +85,14 @@ local function expand_blame_format(fmt: string, name: string, info: BlameInfo):
|
|||
return util.expand_format(fmt, info, config.current_line_blame_formatter_opts.relative_time)
|
||||
end
|
||||
|
||||
local function flatten_virt_text(virt_text: {{string, string}}): string
|
||||
local res = {}
|
||||
for _, part in ipairs(virt_text) do
|
||||
res[#res+1] = part[1]
|
||||
end
|
||||
return table.concat(res)
|
||||
end
|
||||
|
||||
-- Update function, must be called in async context
|
||||
local update = void(function()
|
||||
local bufnr = current_buf()
|
||||
|
@ -147,7 +155,7 @@ local update = void(function()
|
|||
|
||||
vim.b[bufnr].gitsigns_blame_line_dict = result
|
||||
|
||||
if opts.virt_text and result then
|
||||
if result then
|
||||
local virt_text: {{string, string}}
|
||||
local clb_formatter = result.author == 'Not Committed Yet' and
|
||||
config.current_line_blame_formatter_nc or
|
||||
|
@ -165,6 +173,9 @@ local update = void(function()
|
|||
)
|
||||
end
|
||||
|
||||
vim.b[bufnr].gitsigns_blame_line = flatten_virt_text(virt_text)
|
||||
|
||||
if opts.virt_text then
|
||||
set_extmark(bufnr, lnum, {
|
||||
virt_text = virt_text,
|
||||
virt_text_pos = opts.virt_text_pos,
|
||||
|
@ -172,6 +183,7 @@ local update = void(function()
|
|||
hl_mode = 'combine',
|
||||
})
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
M.setup = function()
|
||||
|
|
|
@ -410,6 +410,7 @@ global record vim
|
|||
gitsigns_status_dict: {string:any}
|
||||
gitsigns_status: string
|
||||
gitsigns_blame_line_dict: {string:any}
|
||||
gitsigns_blame_line: string
|
||||
end
|
||||
|
||||
b: BufVar
|
||||
|
|
Loading…
Reference in New Issue