feat(render): dim housekeeping commits by default (#612)

* feat(render): dim housekeeping commits by default

use `LazyComment` highlight group for commits with
housekeeping types, i.e. chore/ci/doc

* refactor: some small improvments to unimportant commits

---------

Co-authored-by: Folke Lemaitre <folke.lemaitre@gmail.com>
This commit is contained in:
kylo252 2023-03-02 14:25:50 +01:00 committed by GitHub
parent 26d121ea13
commit 1f7ffec177
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 3 deletions

View File

@ -9,6 +9,7 @@ M.colors = {
CommitIssue = "Number", CommitIssue = "Number",
CommitType = "Title", -- conventional commit type CommitType = "Title", -- conventional commit type
CommitScope = "Italic", -- conventional commit scope CommitScope = "Italic", -- conventional commit scope
Dimmed = "Conceal", -- property
Prop = "Conceal", -- property Prop = "Conceal", -- property
Value = "@string", -- value of a property Value = "@string", -- value of a property
NoCond = "DiagnosticWarn", -- unloaded icon for a plugin where `cond()` was false NoCond = "DiagnosticWarn", -- unloaded icon for a plugin where `cond()` was false

View File

@ -24,6 +24,8 @@ function M.get_commands()
return ret return ret
end end
M.dimmed_commits = { "build", "ci", "chore", "doc" }
M.keys = { M.keys = {
hover = "K", hover = "K",
diff = "d", diff = "d",

View File

@ -456,15 +456,21 @@ function M:log(task)
self:diagnostic({ message = "Breaking Changes", severity = vim.diagnostic.severity.WARN }) self:diagnostic({ message = "Breaking Changes", severity = vim.diagnostic.severity.WARN })
end end
self:append(ref:sub(1, 7) .. " ", "LazyCommit", { indent = 6 }) self:append(ref:sub(1, 7) .. " ", "LazyCommit", { indent = 6 })
self:append(vim.trim(msg)):highlight({
local dimmed = false
for _, dim in ipairs(ViewConfig.dimmed_commits) do
if msg:find("^" .. dim) then
dimmed = true
end
end
self:append(vim.trim(msg), dimmed and "LazyDimmed" or nil):highlight({
["#%d+"] = "LazyCommitIssue", ["#%d+"] = "LazyCommitIssue",
["^%S+:"] = "LazyCommitType", ["^%S+:"] = dimmed and "Bold" or "LazyCommitType",
["^%S+(%(.*%)):"] = "LazyCommitScope", ["^%S+(%(.*%)):"] = "LazyCommitScope",
["`.-`"] = "@text.literal.markdown_inline", ["`.-`"] = "@text.literal.markdown_inline",
["%*.-%*"] = "Italic", ["%*.-%*"] = "Italic",
["%*%*.-%*%*"] = "Bold", ["%*%*.-%*%*"] = "Bold",
}) })
-- string.gsub
self:append(" " .. time, "LazyComment") self:append(" " .. time, "LazyComment")
self:nl() self:nl()
end end