0

When coc prompts with information about what a class / function does there's help to the right, but if I want to scroll down within this help I have to use the mouse. I'm wondering if there's a nicer alternative?

t

Edit

I have tried using the following:

coc#util#float_scroll({forward})            *coc#util#float_scroll()*

    Return expr for scrolling a floating window forward or backward. ex: >

    nnoremap <expr><C-f> coc#util#has_float() ? coc#util#float_scroll(1) : "\<C-f>"
    nnoremap <expr><C-b> coc#util#has_float() ? coc#util#float_scroll(0) : "\<C-b>"

In my init.vim as

    nnoremap <expr><C-f> coc#util#has_float() ? coc#util#float_scroll(1) : "\<C-f>"
    nnoremap <expr><C-b> coc#util#has_float() ? coc#util#float_scroll(0) : "\<C-b>"

I expected to be able to scroll down with <C-f> and up with <C-b>, neither of these worked though.

4
  • :help ins-completion and the sections on the popup menu didn’t give any scrolling keys of this kind. Maybe coc does?
    – D. Ben Knoble
    Aug 1 '20 at 11:44
  • coc might, I'm not sure, and not sure where to find it.
    – baxx
    Aug 1 '20 at 12:07
  • Maybe here? github.com/neoclide/coc.nvim/blob/…
    – D. Ben Knoble
    Aug 1 '20 at 12:46
  • @D.BenKnoble just tried (edited post) didn't work for me :/
    – baxx
    Aug 1 '20 at 12:58
1

coc#util#float_scroll has been replaced by coc#float#scroll()

The example keymapping has been given in the documentation.

if has('nvim-0.4.3') || has('patch-8.2.0750')
          nnoremap <nowait><expr> <C-f> coc#float#has_scroll() ? coc#float#scroll(1) : "\<C-f>"
          nnoremap <nowait><expr> <C-b> coc#float#has_scroll() ? coc#float#scroll(0) : "\<C-b>"
          inoremap <nowait><expr> <C-f> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(1)\<cr>" : "\<Right>"
          inoremap <nowait><expr> <C-b> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(0)\<cr>" : "\<Left>"
endif

If you want to scroll one line at a time rather than a full page, then you can specify the number of lines in the second argument as follows.

  inoremap <nowait><expr> <C-f> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(1, 1)\<cr>" : "\<Right>"
  inoremap <nowait><expr> <C-b> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(0, -1)\<cr>" : "\<Left>"

Worked on NVIM v0.4.4 on my macOS. Coc installed with vim-plug.
Somehow when I installed it by unzipping from the repo it gave an error.

0

I had to use scroll(0, 1) to scroll backwards 1 line (not scroll(0, -1)):

  inoremap <nowait><expr> <C-f> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(1, 1)\<cr>" : "\<Right>"
  inoremap <nowait><expr> <C-b> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(0, 1)\<cr>" : "\<Left>"
1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.