Skip to content

Commit a6ad24e

Browse files
committed
feat: added methods that can be mapped for scrolling the hover/signatureHelp windows
1 parent 5bd6e30 commit a6ad24e

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

lua/noice/source/lsp/init.lua

+11
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,17 @@ function M.setup()
5151
end
5252
end
5353

54+
function M.scroll(delta)
55+
for _, kind in ipairs({ M.kinds.hover, M.kinds.signature }) do
56+
local message = M.get(kind)
57+
local win = message:win()
58+
if win then
59+
Util.nui.scroll(win, delta)
60+
return
61+
end
62+
end
63+
end
64+
5465
---@param message NoiceMessage
5566
function M.augroup(message)
5667
return "noice_lsp_" .. message.id

lua/noice/util/nui.lua

+16
Original file line numberDiff line numberDiff line change
@@ -235,4 +235,20 @@ function M.anchor(width, height)
235235
return anchor
236236
end
237237

238+
function M.scroll(win, delta)
239+
local info = vim.fn.getwininfo(win)[1] or {}
240+
local top = info.topline or 1
241+
local buf = vim.api.nvim_win_get_buf(win)
242+
top = top + delta
243+
top = math.max(top, 1)
244+
top = math.min(top, M.win_buf_height(win) - info.height + 1)
245+
246+
vim.defer_fn(function()
247+
vim.api.nvim_buf_call(buf, function()
248+
vim.api.nvim_command("normal! " .. top .. "zt")
249+
vim.cmd([[do WinScrolled]])
250+
end)
251+
end, 0)
252+
end
253+
238254
return M

lua/noice/view/nui.lua

+2
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ function NuiView:update_options()
3939
},
4040
win_options = {
4141
foldenable = false,
42+
scrolloff = 0,
43+
sidescrolloff = 0,
4244
},
4345
}, self._opts, self:get_layout())
4446

0 commit comments

Comments
 (0)