Reputation: 23092
I would like to be able to scroll the YouComplete GetDoc
popup with the keyboard in cases where the docstring is too large to fit within the popup. Currently I invoke the popup with <leader>yD
. Here is the relevant snippet from my .vimrc
:
nmap <leader>yd <plug>(YCMHover)
nnoremap <leader>yD :YcmCompleter GetDoc<CR>
let g:ycm_auto_hover = '' " disable auto popups
Here is an example of a docstring that is too large to fit within the popup:
Note that I am using mouse mode in tmux so my mouse scroll is bound to tmux and I'm after a keyboard-based solution. I am using vim 8.2
.
Upvotes: 5
Views: 941
Reputation: 108
For anyone still looking for a keyboard-based solution to this (like I was), you can do this using vim popup.txt.
Below is a handy function I wrote to scroll the view of the latest popup window:
function ScrollPopup(up=0)
if (len(popup_list()) >= 1)
let popid = popup_list()[0]
let firstline = popup_getoptions(popid)['firstline']
if (a:up)
call popup_setoptions(popid, {'firstline': max([1, firstline-1])})
else
call popup_setoptions(popid, {'firstline': firstline+1})
endif
endif
endfunc
You can then map the function to whatever suits your needs, for example:
nnoremap <leader>j :call ScrollPopup()<CR>
nnoremap <leader>k :call ScrollPopup(1)<CR>
Upvotes: 1
Reputation: 623
Maybe you can try this on stackexchange. Although it mainly described for coc in nvim, since ycm also used popup window for DocString, so it also work.
The main idea is to get the current position of cursor, find the nearest popup window and change its firstline.
Upvotes: 0
Reputation: 28470
From the docs
POPUP SCROLLBAR *popup-scrollbar*
If the text does not fit in the popup a scrollbar is displayed on the right of
the window. This can be disabled by setting the "scrollbar" option to zero.
When the scrollbar is displayed mouse scroll events, while the mouse pointer
is on the popup, will cause the text to scroll up or down as you would expect.
A click in the upper half of the scrollbar will scroll the text down one line.
A click in the lower half will scroll the text up one line. However, this is
limited so that the popup does not get smaller.
which makes me strongly believe that that scroll bar is meant to be interacted with via mouse.
Think that even YCM coauthor and maintainer just told me so (it's the wrong chat because I'm a bit slow at times).
Upvotes: 1