mirror of
https://github.com/folke/snacks.nvim
synced 2025-08-04 18:58:12 +00:00
feat(notifier): show indicator when notif has more lines. Closes #112
This commit is contained in:
parent
b4a293aac7
commit
cf72c06ee6
3 changed files with 22 additions and 1 deletions
|
@ -138,6 +138,11 @@ Advanced LSP Progress ~
|
||||||
style = "compact",
|
style = "compact",
|
||||||
top_down = true, -- place notifications from top to bottom
|
top_down = true, -- place notifications from top to bottom
|
||||||
date_format = "%R", -- time format for notifications
|
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
|
refresh = 50, -- refresh at most every 50ms
|
||||||
}
|
}
|
||||||
<
|
<
|
||||||
|
|
|
@ -127,6 +127,11 @@ vim.api.nvim_create_autocmd("LspProgress", {
|
||||||
style = "compact",
|
style = "compact",
|
||||||
top_down = true, -- place notifications from top to bottom
|
top_down = true, -- place notifications from top to bottom
|
||||||
date_format = "%R", -- time format for notifications
|
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
|
refresh = 50, -- refresh at most every 50ms
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
|
@ -123,6 +123,11 @@ local defaults = {
|
||||||
style = "compact",
|
style = "compact",
|
||||||
top_down = true, -- place notifications from top to bottom
|
top_down = true, -- place notifications from top to bottom
|
||||||
date_format = "%R", -- time format for notifications
|
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
|
refresh = 50, -- refresh at most every 50ms
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -519,7 +524,7 @@ function N:render(notif)
|
||||||
for _, line in ipairs(lines) do
|
for _, line in ipairs(lines) do
|
||||||
width = math.max(width, vim.fn.strdisplaywidth(line) + pad)
|
width = math.max(width, vim.fn.strdisplaywidth(line) + pad)
|
||||||
end
|
end
|
||||||
if win.opts.border and win.opts.border ~= "none" and win.opts.border ~= "" then
|
if win:has_border() then
|
||||||
width = width + 2
|
width = width + 2
|
||||||
end
|
end
|
||||||
width = dim(width, self.opts.width.min, self.opts.width.max, vim.o.columns)
|
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)
|
height = height + math.ceil((vim.fn.strdisplaywidth(line) + pad) / width)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
local wanted_height = height
|
||||||
height = dim(height, self.opts.height.min, self.opts.height.max, vim.o.lines)
|
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.width = width
|
||||||
win.opts.height = height
|
win.opts.height = height
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue