Skip to content

Instantly share code, notes, and snippets.

@SmallEndian
Created February 16, 2022 01:25
Show Gist options
  • Select an option

  • Save SmallEndian/758c82dc6c8d46f7923512a97b0a980e to your computer and use it in GitHub Desktop.

Select an option

Save SmallEndian/758c82dc6c8d46f7923512a97b0a980e to your computer and use it in GitHub Desktop.
Hover through the documentation in CoC
" Use K to show documentation in preview window.
" For most purposes (mostly class), it's better to keep the call to man
au Filetype rust,java,go nnoremap <silent> K :call <SID>show_documentation()<CR>
"nnoremap <silent> K :call <SID>show_documentation()<CR>
function! s:show_documentation()
if (index(['vim','help'], &filetype) >= 0)
execute 'h '.expand('<cword>')
else
call CocAction('doHover')
endif
endfunction
" Because everyone deserves a chance to scroll through long documentation:
" ^K jumps into the floating window
" A second ^K closes the floating window and returns to the orignal buffer
" If no floating window exists when the first ^K is pressed, open the floating window
nnoremap <silent> <expr> <C-k> ( coc#float#has_float() ?
\ (exists('w:float') ?
\ ":call coc#float#close_all()<CR>" :
\ ":call coc#float#jump()<CR>") :
\ ":call <SID>show_documentation()<CR>")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment