return ['', '']
enddef
+# Key filter function for the hover popup window.
+# Only keys to scroll the popup window are supported.
+def HoverWinFilterKey(hoverWin: number, key: string): bool
+ var keyHandled = false
+
+ if key == "\<C-E>"
+ || key == "\<C-D>"
+ || key == "\<C-F>"
+ || key == "\<PageDown>"
+ || key == "\<C-Y>"
+ || key == "\<C-U>"
+ || key == "\<C-B>"
+ || key == "\<PageUp>"
+ || key == "\<C-Home>"
+ || key == "\<C-End>"
+ # scroll the hover popup window
+ win_execute(hoverWin, $'normal! {key}')
+ keyHandled = true
+ endif
+
+ if !keyHandled
+ # For any other key, close the hover window
+ hoverWin->popup_close()
+ endif
+
+ return keyHandled
+enddef
+
# process the 'textDocument/hover' reply from the LSP server
# Result: Hover | null
export def HoverReply(lspserver: dict<any>, hoverResult: any, cmdmods: string): void
maxwidth: 80,
minwidth: 80,
border: [0, 1, 0, 1],
- borderchars: [' ']})
+ borderchars: [' '],
+ filter: HoverWinFilterKey})
win_execute(winid, $'setlocal ft={hoverKind}')
endif
enddef
*:LspHover*
:LspHover Show the documentation for the symbol under the cursor
- in a popup window. If you want to show the symbol
- documentation in the |preview-window| instead of in a
- popup window set >
+ in a popup window. The following keys can be used to
+ scroll the popup window:
+
+ <CTRL-E> - Scroll window downwards by a line.
+ <CTRL-D> - Scroll window downwards by 'scroll'
+ lines.
+ <CTRL-F> - Scroll window downards by a page.
+ <PageDown> - ditto.
+ <CTRL-Y> - Scroll window upwards by a line.
+ <CTRL-U> - Scroll window upwards by 'scroll'
+ lines.
+ <CTRL-B> - Scroll window upwards by a page.
+ <PageUp> - ditto.
+ <CTRL-Home> - Goto the first line
+ <CTRL-End> - Goto the last line
+
+ Pressing any other key will close the popup window.
+
+ If you want to show the symbol documentation in the
+ |preview-window| instead of in a popup window set >
LspOptionsSet({'hoverInPreview': true})
<