1 " Popup documentation of specified object under the cursor
2 " Requires github.com/zmb3/gogetdoc in the $PATH
5 if exists("b:gogetdoc_job") && job_status(b:gogetdoc_job) == "run" | return "GD" | endif
9 function! GoGetDocGot(ch)
11 while ch_status(a:ch) == "buffered"
12 let msgs = add(msgs, ch_read(a:ch))
14 if exists("b:godocid") | call popup_close(b:godocid) | endif
16 echohl WarningMsg | echomsg "No go doc" | echohl None
20 let b:godocid = popup_atcursor(msgs[2:-2], {"wrap": 0, "title": msgs[0], "move": "word"})
23 function! s:GoGetDoc()
24 if exists("b:gogetdoc_job") && job_status(b:gogetdoc_job) == "run" | return | endif
25 let pos = line2byte(line(".")) + col(".") - 2
26 let cmdline = "gogetdoc -pos " . expand("%p") . ":#" . pos
28 let b:gogetdoc_job = job_start(cmdline, {
31 \"close_cb": "GoGetDocGot",
35 nmap <buffer> <silent> <CR> :call <SID>GoGetDoc()<CR>