Skip to content

Commit 272c9a9

Browse files
committed
feat(confirm): configurable alignment of choices line
Signed-off-by: Max Englander <[email protected]>
1 parent 0427460 commit 272c9a9

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

lua/noice/config/format.lua

+3
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,9 @@ M.defaults = {
151151
},
152152
---@class NoiceFormatOptions.confirm
153153
confirm = {
154+
choices = {
155+
align = "center",
156+
},
154157
hl_group = {
155158
choice = "NoiceFormatConfirm",
156159
default_choice = "NoiceFormatConfirmDefault",

lua/noice/text/format/formatters.lua

+11-2
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,17 @@ function M.confirm(message, opts, input)
190190
end
191191
end
192192

193-
local padding = math.floor((message:width() - message:last_line():width()) / 2)
194-
table.insert(message:last_line()._texts, 1, NoiceText((" "):rep(padding)))
193+
if opts.choices then
194+
if opts.choices.align == "center" then
195+
local padding = math.floor((message:width() - message:last_line():width()) / 2)
196+
table.insert(message:last_line()._texts, 1, NoiceText((" "):rep(padding)))
197+
elseif opts.choices.align == "right" then
198+
local padding = math.floor((message:width() - message:last_line():width()))
199+
table.insert(message:last_line()._texts, 1, NoiceText((" "):rep(padding)))
200+
elseif opts.choices.align ~= "left" then
201+
Util.panic("Invalid confirm formatter align value %s", opts.choices.align)
202+
end
203+
end
195204
end
196205
end
197206

0 commit comments

Comments
 (0)