Skip to content

Commit 92a8fbb

Browse files
committed
feat!: remove current_line_blame_formatter_opts
- Also make relative time the default time format for current_line_blame_formatter - When `current_line_blame_formatter` is passed as a function it is no longer passed an opts argument.
1 parent 61f5b64 commit 92a8fbb

File tree

5 files changed

+10
-59
lines changed

5 files changed

+10
-59
lines changed

README.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,7 @@ require('gitsigns').setup {
8282
ignore_whitespace = false,
8383
virt_text_priority = 100,
8484
},
85-
current_line_blame_formatter = '<author>, <author_time:%Y-%m-%d> - <summary>',
86-
current_line_blame_formatter_opts = {
87-
relative_time = false,
88-
},
85+
current_line_blame_formatter = '<author>, <author_time:%R> - <summary>',
8986
sign_priority = 6,
9087
update_debounce = 100,
9188
status_formatter = nil, -- Use default

doc/gitsigns.txt

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,7 @@ of the default settings:
5959
ignore_whitespace = false,
6060
virt_text_priority = 100,
6161
},
62-
current_line_blame_formatter = '<author>, <author_time:%Y-%m-%d> - <summary>',
63-
current_line_blame_formatter_opts = {
64-
relative_time = false,
65-
},
62+
current_line_blame_formatter = '<author>, <author_time:%R> - <summary>',
6663
sign_priority = 6,
6764
update_debounce = 100,
6865
status_formatter = nil, -- Use default
@@ -828,23 +825,8 @@ current_line_blame_opts *gitsigns-config-current_line_blame_opts*
828825
• extra_opts: string[]
829826
Extra options passed to `git-blame`.
830827

831-
current_line_blame_formatter_opts
832-
*gitsigns-config-current_line_blame_formatter_opts*
833-
DEPRECATED
834-
835-
Type: `table[extended]`
836-
Default: >
837-
`{
838-
relative_time = false
839-
}`
840-
<
841-
Options for the current line blame annotation formatter.
842-
843-
Fields: ~
844-
• relative_time: boolean
845-
846828
current_line_blame_formatter *gitsigns-config-current_line_blame_formatter*
847-
Type: `string|function`, Default: `" <author>, <author_time> - <summary> "`
829+
Type: `string|function`, Default: `" <author>, <author_time:%R> - <summary> "`
848830

849831
String or function used to format the virtual text of
850832
|gitsigns-config-current_line_blame|.
@@ -913,9 +895,6 @@ current_line_blame_formatter *gitsigns-config-current_line_blame_formatter*
913895
Note that the keys map onto the output of:
914896
`git blame --line-porcelain`
915897

916-
{opts} Passed directly from
917-
|gitsigns-config-current_line_blame_formatter_opts|.
918-
919898
Return: ~
920899
The result of this function is passed directly to the `opts.virt_text`
921900
field of |nvim_buf_set_extmark| and thus must be a list of

lua/gitsigns/config.lua

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,7 @@
4646
--- | 'changedelete'
4747
--- | 'untracked'
4848

49-
--- @class (exact) Gitsigns.CurrentLineBlameFmtOpts
50-
--- @field relative_time boolean
51-
52-
--- @alias Gitsigns.CurrentLineBlameFmtFun fun(user: string, info: table<string,any>, opts: Gitsigns.CurrentLineBlameFmtOpts): {[1]:string,[2]:string}[]
49+
--- @alias Gitsigns.CurrentLineBlameFmtFun fun(user: string, info: table<string,any>): {[1]:string,[2]:string}[]
5350

5451
--- @class (exact) Gitsigns.CurrentLineBlameOpts : Gitsigns.BlameOpts
5552
--- @field virt_text? boolean
@@ -85,7 +82,6 @@
8582
--- @field update_debounce integer
8683
--- @field status_formatter fun(_: table<string,any>): string
8784
--- @field current_line_blame boolean
88-
--- @field current_line_blame_formatter_opts { relative_time: boolean }
8985
--- @field current_line_blame_formatter string|Gitsigns.CurrentLineBlameFmtFun
9086
--- @field current_line_blame_formatter_nc string|Gitsigns.CurrentLineBlameFmtFun
9187
--- @field current_line_blame_opts Gitsigns.CurrentLineBlameOpts
@@ -108,7 +104,6 @@ local M = {
108104
DiffOpts = {},
109105
SignConfig = {},
110106
watch_gitdir = {},
111-
current_line_blame_formatter_opts = {},
112107
current_line_blame_opts = {},
113108
Worktree = {},
114109
},
@@ -688,24 +683,9 @@ M.schema = {
688683
]],
689684
},
690685

691-
current_line_blame_formatter_opts = {
692-
type = 'table',
693-
deep_extend = true,
694-
deprecated = true,
695-
default = {
696-
relative_time = false,
697-
},
698-
description = [[
699-
Options for the current line blame annotation formatter.
700-
701-
Fields: ~
702-
• relative_time: boolean
703-
]],
704-
},
705-
706686
current_line_blame_formatter = {
707687
type = { 'string', 'function' },
708-
default = ' <author>, <author_time> - <summary> ',
688+
default = ' <author>, <author_time:%R> - <summary> ',
709689
description = [[
710690
String or function used to format the virtual text of
711691
|gitsigns-config-current_line_blame|.
@@ -774,9 +754,6 @@ M.schema = {
774754
Note that the keys map onto the output of:
775755
`git blame --line-porcelain`
776756
777-
{opts} Passed directly from
778-
|gitsigns-config-current_line_blame_formatter_opts|.
779-
780757
Return: ~
781758
The result of this function is passed directly to the `opts.virt_text`
782759
field of |nvim_buf_set_extmark| and thus must be a list of

lua/gitsigns/current_line_blame.lua

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ local function expand_blame_format(fmt, name, info)
2828
if info.author == name then
2929
info.author = 'You'
3030
end
31-
return util.expand_format(fmt, info, config.current_line_blame_formatter_opts.relative_time)
31+
return util.expand_format(fmt, info)
3232
end
3333

3434
--- @param virt_text {[1]: string, [2]: string}[]
@@ -41,7 +41,6 @@ local function flatten_virt_text(virt_text)
4141
return table.concat(res)
4242
end
4343

44-
--- @param winid integer
4544
--- @return integer
4645
local function win_width()
4746
local winid = api.nvim_get_current_win()
@@ -61,7 +60,7 @@ end
6160
--- @param fmt string
6261
--- @return Gitsigns.CurrentLineBlameFmtFun
6362
local function default_formatter(fmt)
64-
return function(username, blame_info, _opts)
63+
return function(username, blame_info)
6564
return {
6665
{
6766
expand_blame_format(fmt, username, blame_info),
@@ -85,7 +84,7 @@ local function get_blame_virt_text(bufnr, blame_info)
8584
clb_formatter = default_formatter(clb_formatter)
8685
end
8786

88-
return clb_formatter(git_obj.repo.username, blame_info, config.current_line_blame_formatter_opts)
87+
return clb_formatter(git_obj.repo.username, blame_info)
8988
end
9089

9190
--- @param bufnr integer

lua/gitsigns/util.lua

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -264,9 +264,8 @@ end
264264

265265
---@param fmt string
266266
---@param info table<string,any>
267-
---@param reltime? boolean Use relative time as the default date format
268267
---@return string
269-
function M.expand_format(fmt, info, reltime)
268+
function M.expand_format(fmt, info)
270269
local ret = {} --- @type string[]
271270

272271
for _ = 1, 20 do -- loop protection
@@ -287,7 +286,7 @@ function M.expand_format(fmt, info, reltime)
287286
end
288287
if vim.endswith(key, '_time') then
289288
if time_fmt == '' then
290-
time_fmt = reltime and '%R' or '%Y-%m-%d'
289+
time_fmt = '%Y-%m-%d'
291290
end
292291
v = expand_date(time_fmt, v)
293292
end

0 commit comments

Comments
 (0)