diff --git a/lua/snacks/picker/config/highlights.lua b/lua/snacks/picker/config/highlights.lua index d26a4942..9a40c64c 100644 --- a/lua/snacks/picker/config/highlights.lua +++ b/lua/snacks/picker/config/highlights.lua @@ -57,6 +57,7 @@ Snacks.util.set_hl({ GitBranchCurrent = "Number", GitDate = "Special", GitIssue = "Number", + GitAuthor = "Constant", GitType = "Title", -- conventional commit type GitScope = "Italic", -- conventional commit scope GitStatus = "Special", diff --git a/lua/snacks/picker/format.lua b/lua/snacks/picker/format.lua index fe3569d1..c51cd60d 100644 --- a/lua/snacks/picker/format.lua +++ b/lua/snacks/picker/format.lua @@ -212,6 +212,9 @@ function M.git_log(item, picker) msg = body end ret[#ret + 1] = { msg, msg_hl } + if item.author then + ret[#ret + 1] = { " <" .. item.author .. ">", "SnacksPickerGitAuthor" } + end Snacks.picker.highlight.markdown(ret) Snacks.picker.highlight.highlight(ret, { ["#%d+"] = "SnacksPickerGitIssue", diff --git a/lua/snacks/picker/preview.lua b/lua/snacks/picker/preview.lua index 2dea1df4..56cd1616 100644 --- a/lua/snacks/picker/preview.lua +++ b/lua/snacks/picker/preview.lua @@ -321,7 +321,7 @@ function M.git_log(ctx) ctx, "--no-pager", "log", - "--pretty=format:%h %s (%ch)", + "--pretty=format:%h %s (%ch) <%an>", "--abbrev-commit", "--decorate", "--date=short", @@ -335,7 +335,7 @@ function M.git_log(ctx) ft = "git", ---@param text string add = function(text) - local commit, msg, date = text:match("^(%S+) (.*) %((.*)%)$") + local commit, msg, date, author = text:match("^(%S+) (.*) %((.*)%) <(.*)>$") if commit then row = row + 1 local hl = Snacks.picker.format.git_log({ @@ -345,6 +345,7 @@ function M.git_log(ctx) commit = commit, msg = msg, date = date, + author = author, }, ctx.picker) Snacks.picker.highlight.set(ctx.buf, ns, row, hl) end diff --git a/lua/snacks/picker/source/git.lua b/lua/snacks/picker/source/git.lua index 8de2b849..bdc062a9 100644 --- a/lua/snacks/picker/source/git.lua +++ b/lua/snacks/picker/source/git.lua @@ -94,7 +94,7 @@ function M.log(opts, ctx) local args = git_args( opts.args, "log", - "--pretty=format:%h %s (%ch)", + "--pretty=format:%h %s (%ch) <%an>", "--abbrev-commit", "--decorate", "--date=short", @@ -168,7 +168,7 @@ function M.log(opts, ctx) args = args, ---@param item snacks.picker.finder.Item transform = function(item) - local commit, msg, date = item.text:match("^(%S+) (.*) %((.*)%)$") + local commit, msg, date, author = item.text:match("^(%S+) (.*) %((.*)%) <(.*)>$") if not commit then Snacks.notify.error(("failed to parse log item:\n%q"):format(item.text)) return false @@ -177,6 +177,7 @@ function M.log(opts, ctx) item.commit = commit item.msg = msg item.date = date + item.author = author item.file = file item.files = renames end,