Skip to content

Commit dd9c0aa

Browse files
committed
feat(commit): styling improvements for message input
1 parent 9923b7e commit dd9c0aa

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

lua/tinygit/commands/commit/msg-input.lua

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -136,13 +136,12 @@ local function setupSeparator(width)
136136
local function updateSeparator()
137137
local ns = vim.api.nvim_create_namespace("tinygit.commitMsgInput")
138138
vim.api.nvim_buf_clear_namespace(state.bufnr, ns, 0, -1)
139-
local separator = { char = "", hlgroup = "Comment" }
139+
local separator = { char = "", hlgroup = "NonText" }
140140

141141
vim.api.nvim_buf_set_extmark(state.bufnr, ns, 0, 0, {
142142
virt_lines = {
143-
{ { separator.char:rep(width), separator.hlgroup } },
143+
{ { separator.char:rep(width - 2), separator.hlgroup } },
144144
},
145-
virt_lines_leftcol = true,
146145
})
147146
end
148147
updateSeparator() -- initialize
@@ -206,14 +205,14 @@ function M.new(mode, prompt, confirmationCallback)
206205
local keymapHints = {}
207206
if conf.keymapHints then
208207
local nmaps = conf.keymaps.normal
209-
local hlgroup = { key = "Comment", desc = "NonText" }
208+
local hlgroupKey, hlgroupDesc = "Comment", "NonText"
210209
keymapHints = {
211210
{ " normal: ", "FloatBorder" },
212-
{ " " .. nmaps.confirm, hlgroup.key },
213-
{ " confirm ", hlgroup.desc },
211+
{ " " .. nmaps.confirm, hlgroupKey },
212+
{ " confirm ", hlgroupDesc },
214213
{ " " },
215-
{ " " .. nmaps.abort, hlgroup.key },
216-
{ " abort ", hlgroup.desc },
214+
{ " " .. nmaps.abort, hlgroupKey },
215+
{ " abort ", hlgroupDesc },
217216
{ " " },
218217
}
219218
end

lua/tinygit/commands/commit/preview.lua

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,12 @@ local function highlightPreviewWin(bufnr, stagedLines, diffstatLines)
9494
vim.fn.matchadd(hl[1], pattern)
9595
end
9696

97-
-- highlight diffstat for UNSTAGED lines
97+
-- highlight diffstat for UNSTAGED lines (if any)
9898
local ns = vim.api.nvim_create_namespace("tinygit.commitPreview")
99-
vim.hl.range(bufnr, ns, "Comment", { stagedLines, 0 }, { diffstatLines, 0 }, { priority = 1000 })
99+
vim.hl.range(bufnr, ns, "Comment", { stagedLines, 0 }, { diffstatLines - 1, -1 })
100+
101+
-- highlight separator line
102+
vim.hl.range(bufnr, ns, "NonText", { diffstatLines, 0 }, { diffstatLines, -1 })
100103

101104
-- highlight log lines
102105
local highlights = require("tinygit.shared.highlights")
@@ -114,7 +117,7 @@ function M.createWin(mode, inputWinid)
114117
local textWidth = inputWin.width - 2
115118
local diffStatLines, summary, stagedLinesCount = M.getDiffStats(mode, textWidth)
116119
local diffstatLineCount = #diffStatLines -- save, since `list_extend` mutates
117-
table.insert(diffStatLines, "") -- line break
120+
table.insert(diffStatLines, (""):rep(textWidth)) -- separator
118121
local logLines = M.getGitLog()
119122
local previewLines = vim.list_extend(diffStatLines, logLines)
120123

@@ -142,7 +145,7 @@ function M.createWin(mode, inputWinid)
142145
vim.bo[bufnr].filetype = "tinygit.diffstats"
143146
vim.wo[winid].statuscolumn = " " -- = left-padding
144147

145-
vim.wo[winid].winhighlight = "FloatFooter:NonText,FloatBorder:Comment,Normal:Normal"
148+
vim.wo[winid].winhighlight = "FloatFooter:Comment,FloatBorder:Comment,Normal:Normal"
146149
vim.api.nvim_win_call(
147150
winid,
148151
function() highlightPreviewWin(bufnr, stagedLinesCount, diffstatLineCount) end

0 commit comments

Comments
 (0)