From a15126b2deeb423c9ed76aad692102970880c144 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Thu, 2 Mar 2023 14:10:19 +0100 Subject: [PATCH] refactor: some small improvments to unimportant commits --- lua/lazy/view/colors.lua | 1 + lua/lazy/view/config.lua | 2 ++ lua/lazy/view/render.lua | 28 ++++++++++++++-------------- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/lua/lazy/view/colors.lua b/lua/lazy/view/colors.lua index 550ed09..333af82 100644 --- a/lua/lazy/view/colors.lua +++ b/lua/lazy/view/colors.lua @@ -9,6 +9,7 @@ M.colors = { CommitIssue = "Number", CommitType = "Title", -- conventional commit type CommitScope = "Italic", -- conventional commit scope + Dimmed = "Conceal", -- property Prop = "Conceal", -- property Value = "@string", -- value of a property NoCond = "DiagnosticWarn", -- unloaded icon for a plugin where `cond()` was false diff --git a/lua/lazy/view/config.lua b/lua/lazy/view/config.lua index 1f38540..6c73d40 100644 --- a/lua/lazy/view/config.lua +++ b/lua/lazy/view/config.lua @@ -24,6 +24,8 @@ function M.get_commands() return ret end +M.dimmed_commits = { "build", "ci", "chore", "doc" } + M.keys = { hover = "K", diff = "d", diff --git a/lua/lazy/view/render.lua b/lua/lazy/view/render.lua index e4b4224..00f4072 100644 --- a/lua/lazy/view/render.lua +++ b/lua/lazy/view/render.lua @@ -456,21 +456,21 @@ function M:log(task) self:diagnostic({ message = "Breaking Changes", severity = vim.diagnostic.severity.WARN }) end self:append(ref:sub(1, 7) .. " ", "LazyCommit", { indent = 6 }) - if msg:match([[^chore]]) or msg:match([[^ci]]) or msg:match([[^doc]]) then - self:append(vim.trim(msg)):highlight({ - ["."] = "LazyComment", - }) - else - self:append(vim.trim(msg)):highlight({ - ["#%d+"] = "LazyCommitIssue", - ["^%S+:"] = "LazyCommitType", - ["^%S+(%(.*%)):"] = "LazyCommitScope", - ["`.-`"] = "@text.literal.markdown_inline", - ["%*.-%*"] = "Italic", - ["%*%*.-%*%*"] = "Bold", - }) + + local dimmed = false + for _, dim in ipairs(ViewConfig.dimmed_commits) do + if msg:find("^" .. dim) then + dimmed = true + end end - -- string.gsub + self:append(vim.trim(msg), dimmed and "LazyDimmed" or nil):highlight({ + ["#%d+"] = "LazyCommitIssue", + ["^%S+:"] = dimmed and "Bold" or "LazyCommitType", + ["^%S+(%(.*%)):"] = "LazyCommitScope", + ["`.-`"] = "@text.literal.markdown_inline", + ["%*.-%*"] = "Italic", + ["%*%*.-%*%*"] = "Bold", + }) self:append(" " .. time, "LazyComment") self:nl() end