Add do#show_documentation() using coc.nvim

Change the `K` normal mode overrides to use the example given in the
coc.nvim README file which uses Vim's builtin help when in `vim` or
`help` files, or checks if coc.nvim is ready and invokes
`CocActionAsync('doHover')`, otherwise fallback to using `keywordprg`.
This commit is contained in:
2021-02-22 20:48:33 +00:00
parent ecd8659df7
commit 3a2337cd63
6 changed files with 17 additions and 17 deletions

View File

@@ -100,3 +100,14 @@ endfunction
" A sink for mappings to do nothing
function! do#sink() abort
endfunction
" Used by normal mode K mapping to show documentation
function! do#show_documentation()
if index(['vim','help'], &filetype) >= 0
execute 'help '.expand('<cword>')
elseif coc#rpc#ready() " TODO: Check if the LS supports doHover
call CocActionAsync('doHover')
else
execute '!'.&keywordprg.' '.expand('<cword>')
endif
endfunction