]> Sergey Matveev's repositories - dotfiles.git/blobdiff - vim/.vim/ftplugin/go/gogetdoc.vim
Vim scripts refactoring
[dotfiles.git] / vim / .vim / ftplugin / go / gogetdoc.vim
index 9105258bc3288fad8369abe68cc2007f1e7c8248..82496e5964163605905b61ee25090649cce3c090 100644 (file)
@@ -1,35 +1,3 @@
-" Popup documentation of specified object under the cursor
-" Requires github.com/zmb3/gogetdoc in the $PATH
-
-function! LintStatus()
-    if exists("b:gogetdoc_job") && job_status(b:gogetdoc_job) == "run" | return "GD" | endif
-    return ""
-endfunction
-
-function! GoGetDocGot(ch)
-    let msgs = []
-    while ch_status(a:ch) == "buffered"
-        let msgs = add(msgs, ch_read(a:ch))
-    endwhile
-    if exists("b:godocid") | call popup_close(b:godocid) | endif
-    if len(msgs) == 0
-        echohl WarningMsg | echomsg "No go doc" | echohl None
-        return
-    endif
-    let msgs = msgs[2:]
-    let b:godocid = popup_atcursor(msgs[2:-2], {"wrap": 0, "title": msgs[0], "move": "word"})
-endfunction
-
-function! s:GoGetDoc()
-    if exists("b:gogetdoc_job") && job_status(b:gogetdoc_job) == "run" | return | endif
-    let pos = line2byte(line(".")) + col(".") - 2
-    let cmdline = "gogetdoc -pos " . expand("%p") . ":#" . pos
-    echomsg cmdline
-    let b:gogetdoc_job = job_start(cmdline, {
-        \"in_mode": "nl",
-        \"err_io": "null",
-        \"close_cb": "GoGetDocGot",
-    \})
-endfunction
-
-nmap <buffer> <silent> <CR> :call <SID>GoGetDoc()<CR>
+if exists("*go#getdoc#do") | finish | endif
+let b:lint_status_func=function("go#getdoc#status")
+nmap <buffer> <silent> <CR> :call go#getdoc#do()<CR>