feat(win): Snacks.win:scroll

This commit is contained in:
Folke Lemaitre 2024-12-31 06:02:36 +01:00
parent 7383edaec8
commit a1da66e3bf
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040

View file

@ -98,6 +98,8 @@ Snacks.config.style("minimal", {
},
})
local SCROLL_UP, SCROLL_DOWN = Snacks.util.keycode("<c-u>"), Snacks.util.keycode("<c-d>")
local split_commands = {
editor = {
top = "topleft",
@ -246,6 +248,14 @@ function M:focus()
end
end
---@param up? boolean
function M:scroll(up)
vim.api.nvim_buf_call(self.buf, function()
vim.cmd(("normal! %s"):format(up and SCROLL_UP or SCROLL_DOWN))
end)
end
---@param opts? { buf: boolean }
function M:close(opts)
opts = opts or {}