如何使用键盘滚动 YouCompleteMe GetDoc 弹出窗口?

问题描述 投票:0回答:3

我希望能够在文档字符串太大而无法放入弹出窗口的情况下使用键盘滚动 YouComplete

GetDoc
弹出窗口。目前我使用
<leader>yD
调用弹出窗口。这是我的
.vimrc
的相关片段:

nmap <leader>yd <plug>(YCMHover)
nnoremap <leader>yD :YcmCompleter GetDoc<CR>
let g:ycm_auto_hover = '' " disable auto popups

这是一个文档字符串的示例,该文档字符串太大而无法容纳在弹出窗口中:

请注意,我在 tmux 中使用鼠标模式,因此我的鼠标滚动绑定到 tmux,并且我正在寻求基于键盘的解决方案。我正在使用

vim 8.2

vim youcompleteme
3个回答
1
投票

来自文档

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.

这让我坚信滚动条应该通过鼠标进行交互。

认为甚至 YCM 合著者和维护者也这么告诉我(这是错误的聊天,因为我有时有点慢)。


0
投票

也许你可以在stackexchange上尝试一下。虽然主要是针对 nvim 中的 coc 进行描述,但由于 ycm 也使用了 DocString 的弹出窗口,所以它也可以工作。

主要思想是获取光标当前位置,找到最近的弹出窗口并更改其第一行。


0
投票

对于任何仍在寻找基于键盘的解决方案的人(就像我一样),您可以使用 vim popup.txt

下面是我编写的一个方便的函数,用于滚动最新弹出窗口的视图:

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

然后您可以将函数映射到适合您需要的任何位置,例如:

nnoremap <leader>j :call ScrollPopup()<CR>
nnoremap <leader>k :call ScrollPopup(1)<CR>
© www.soinside.com 2019 - 2024. All rights reserved.