coc-clangd icon indicating copy to clipboard operation
coc-clangd copied to clipboard

Signature help is not useful when documentation is long

Open kadircet opened this issue 5 years ago • 6 comments

Since this is the first issue in the repo, let me clarify why I(and possibly others) will file bugs in here:

This extension might not be the right place to fix most of those issues, it might even be the case that these are not issues but just people having different taste, but we are rather trying to keep track of annoying/suboptimal behaviours we face.

This one is about signature help floating window, when the documentation is too long for a signature, the signature itself gets lost. Even though there is a scrollbar, at least I have no idea how to scroll it. It might make sense to always put the signature first, and then put documentation below it.

Here's a screenshot: Screenshot from 2020-02-19 14-20-38

kadircet avatar Feb 19 '20 13:02 kadircet

Fairly sure this needs to be fixed in coc itself.

It might make sense to always put the signature first, and then put documentation below it.

Do you mean signature above documentation inside the floating window? That may end up with the signature a few lines away from the code, and they compete for space. I think I'd prefer having the signatures in a float above the current line, and the docs in a separate float below it. (Downside is we cover up more of the code) WDYT?

sam-mccall avatar Feb 19 '20 13:02 sam-mccall

well i would definitely prefer that if we can have multiple floating windows in flight :D

kadircet avatar Feb 19 '20 13:02 kadircet

At a technical level, certainly possible:

:call popup_create(["one","two"], #{pos: 'botleft', line: 'cursor-1', col:'cursor'})
:call popup_create(["three","four"], #{pos: 'topleft', line: 'cursor+1', col:'cursor'})

Would need some changes - I think another FloatFactory in handler/index.ts.

sam-mccall avatar Feb 20 '20 00:02 sam-mccall

Maybe we should short the signature document from server. Usually, I don't use floating window to show signature, use echo instead. We should not abuse the floating window.

fannheyward avatar Feb 24 '20 08:02 fannheyward

These are my relevant confs which may be of interest for your issues with how floats show. First, where it's displayed by default is as it is to resemble how VSCode do it, but personally I don't like it, for example I don't like signatureHelp at the top, nor both signatureHelp and completion showing at the same time. You may do the same from jsonc conf, I prefer it all from .vimrc:

call coc#config('signature', {
\   'preferShownAbove': v:false
\ })

function! s:coc_close_floats() abort
  for i in range(1, winnr('$'))
    if getwinvar(i, 'float')
      call coc#util#close_win(win_getid(i))
    endif
  endfor
endfunction
autocmd vimrc CompleteChanged * call s:coc_close_floats()

For more info on that check discussion at https://github.com/neoclide/coc.nvim/issues/990.

oblitum avatar Apr 22 '20 02:04 oblitum

For NeoVim, I also have float scrolling from keyboard setup, so I don't have to touch mouse to scroll docs in the event I need it.

" INSERT mode floating window scrolling {{{
function! s:coc_float_scroll(forward) abort
  let float = coc#util#get_float()
  if !float | return '' | endif
  let buf = nvim_win_get_buf(float)
  let buf_height = nvim_buf_line_count(buf)
  let win_height = nvim_win_get_height(float)
  if buf_height < win_height | return '' | endif
  let pos = nvim_win_get_cursor(float)
  if a:forward
    if pos[0] == 1
      let pos[0] += 3 * win_height / 4
    elseif pos[0] + win_height / 2 + 1 < buf_height
      let pos[0] += win_height / 2 + 1
    endif
    let pos[0] = pos[0] < buf_height ? pos[0] : buf_height
  else
    if pos[0] == buf_height
      let pos[0] -= 3 * win_height / 4
    elseif pos[0] - win_height / 2 + 1  > 1
      let pos[0] -= win_height / 2 + 1
    endif
    let pos[0] = pos[0] > 1 ? pos[0] : 1
  endif
  call nvim_win_set_cursor(float, pos)
  return ''
endfunction
" }}}

nnoremap <silent><expr> <down> coc#util#has_float() ? coc#util#float_scroll(1) : "\<down>"
nnoremap <silent><expr> <up> coc#util#has_float() ? coc#util#float_scroll(0) : "\<up>"
inoremap <silent><expr> <down> coc#util#has_float() ? <SID>coc_float_scroll(1) : "\<down>"
inoremap <silent><expr> <up> coc#util#has_float() ? <SID>coc_float_scroll(0) : "\<up>"
vnoremap <silent><expr> <down> coc#util#has_float() ? <SID>coc_float_scroll(1) : "\<down>"
vnoremap <silent><expr> <up> coc#util#has_float() ? <SID>coc_float_scroll(0) : "\<up>"

This discussion provides a technique for Vim: https://github.com/neoclide/coc.nvim/issues/1405.

oblitum avatar Apr 22 '20 02:04 oblitum