Skip to content

Commit 8764567

Browse files
committed
feat: config showOnlyTimeIfAuthor for blame statusline
1 parent 10cbbd9 commit 8764567

3 files changed

Lines changed: 8 additions & 2 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ require("tinygit").setup {
193193
blame = {
194194
ignoreAuthors = {}, -- hide component if from these authors (useful for bots)
195195
hideAuthorNames = {}, -- show component, but hide names (useful for your own name)
196+
showOnlyTimeIfAuthor = {}, -- show only time if author is in this list
196197
maxMsgLen = 40,
197198
icon = "",
198199
},

lua/tinygit/config.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ local defaultConfig = {
106106
blame = {
107107
ignoreAuthors = {}, -- hide component if from these authors (useful for bots)
108108
hideAuthorNames = {}, -- show component, but hide names (useful for your own name)
109+
showOnlyTimeIfAuthor = {}, -- show only time if author is in this list
109110
maxMsgLen = 40,
110111
icon = "",
111112
},

lua/tinygit/statusline/blame.lua

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,17 @@ local function getBlame(bufnr)
3737
:gsub(" ", "")
3838
:gsub("%d+s", "just now") -- secs -> just now
3939
if not shortRelDate:find("just now") then shortRelDate = shortRelDate .. " ago" end
40+
41+
if vim.list_contains(config.showOnlyTimeIfAuthor, author) then
42+
return vim.trim(("%s %s"):format(config.icon, shortRelDate))
43+
end
44+
4045
local trimmedMsg = #msg <= config.maxMsgLen and msg
4146
or vim.trim(msg:sub(1, config.maxMsgLen)) .. ""
4247
local authorInitials = not (author:find("%s")) and author:sub(1, 2) -- "janedoe" -> "ja"
4348
or author:sub(1, 1) .. author:match("%s(%S)") -- "Jane Doe" -> "JD"
44-
local authorStr = vim.tbl_contains(config.hideAuthorNames, author) and ""
49+
local authorStr = vim.list_contains(config.hideAuthorNames, author) and ""
4550
or " by " .. authorInitials
46-
4751
return vim.trim(("%s %s [%s%s]"):format(config.icon, trimmedMsg, shortRelDate, authorStr))
4852
end
4953

0 commit comments

Comments
 (0)