Created
February 16, 2022 01:25
-
-
Save SmallEndian/758c82dc6c8d46f7923512a97b0a980e to your computer and use it in GitHub Desktop.
Hover through the documentation in CoC
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| " 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