feat(notifier): show indicator when notif has more lines. Closes #112

This commit is contained in:
Folke Lemaitre 2024-11-20 20:15:41 +01:00
parent b4a293aac7
commit cf72c06ee6
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040
3 changed files with 22 additions and 1 deletions

View file

@ -138,6 +138,11 @@ Advanced LSP Progress ~
style = "compact",
top_down = true, -- place notifications from top to bottom
date_format = "%R", -- time format for notifications
-- format for footer when more lines are available
-- `%d` is replaced with the number of lines.
-- only works for styles with a border
---@type string|boolean
more_format = " ↓ %d lines ",
refresh = 50, -- refresh at most every 50ms
}
<

View file

@ -127,6 +127,11 @@ vim.api.nvim_create_autocmd("LspProgress", {
style = "compact",
top_down = true, -- place notifications from top to bottom
date_format = "%R", -- time format for notifications
-- format for footer when more lines are available
-- `%d` is replaced with the number of lines.
-- only works for styles with a border
---@type string|boolean
more_format = " ↓ %d lines ",
refresh = 50, -- refresh at most every 50ms
}
```

View file

@ -123,6 +123,11 @@ local defaults = {
style = "compact",
top_down = true, -- place notifications from top to bottom
date_format = "%R", -- time format for notifications
-- format for footer when more lines are available
-- `%d` is replaced with the number of lines.
-- only works for styles with a border
---@type string|boolean
more_format = " ↓ %d lines ",
refresh = 50, -- refresh at most every 50ms
}
@ -519,7 +524,7 @@ function N:render(notif)
for _, line in ipairs(lines) do
width = math.max(width, vim.fn.strdisplaywidth(line) + pad)
end
if win.opts.border and win.opts.border ~= "none" and win.opts.border ~= "" then
if win:has_border() then
width = width + 2
end
width = dim(width, self.opts.width.min, self.opts.width.max, vim.o.columns)
@ -532,8 +537,14 @@ function N:render(notif)
height = height + math.ceil((vim.fn.strdisplaywidth(line) + pad) / width)
end
end
local wanted_height = height
height = dim(height, self.opts.height.min, self.opts.height.max, vim.o.lines)
if wanted_height > height and win:has_border() and self.opts.more_format and not win.opts.footer then
win.opts.footer = self.opts.more_format:format(wanted_height - height)
win.opts.footer_pos = "right"
end
win.opts.width = width
win.opts.height = height
end