Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add g:go_doc_balloon #3252

Merged
merged 3 commits into from
Jun 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions autoload/go/config.vim
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,10 @@ function! go#config#DebugMappings() abort
return extend(l:user, l:default, 'keep')
endfunction

function! go#config#DocBalloon() abort
return get(g:, 'go_doc_balloon', 0)
endfunction

" Set the default value. A value of "1" is a shortcut for this, for
" compatibility reasons.
if exists("g:go_gorename_prefill") && g:go_gorename_prefill == 1
Expand Down
18 changes: 14 additions & 4 deletions autoload/go/lsp.vim
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ function! s:newlsp() abort
call remove(self.notificationQueue[l:fname], 0)
endif
catch
call go#util#EchoError(printf('%s: %s', v:throwpoint, v:exception))
"call go#util#EchoError(printf('%s: %s', v:throwpoint, v:exception))
endtry
endfor
endfunction
Expand Down Expand Up @@ -970,8 +970,18 @@ function! s:hoverHandler(next, msg) abort dict

try
let l:value = json_decode(a:msg.contents.value)
let l:args = [l:value.signature]
call call(a:next, l:args)

let l:signature = split(l:value.signature, "\n")
let l:msg = l:signature
if go#config#DocBalloon()
" use synopsis instead of fullDocumentation to keep the hover window
" small.
let l:doc = l:value.synopsis
if len(l:doc) isnot 0
let l:msg = l:signature + ['', l:doc]
endif
endif
call call(a:next, [l:msg])
catch
" TODO(bc): log the message and/or show an error message.
endtry
Expand Down Expand Up @@ -1874,7 +1884,7 @@ function! s:lineinfile(fname, line) abort

return l:filecontents[-1]
catch
call go#util#EchoError(printf('%s (line %s): %s at %s', a:fname, a:line, v:exception, v:throwpoint))
"call go#util#EchoError(printf('%s (line %s): %s at %s', a:fname, a:line, v:exception, v:throwpoint))
return -1
endtry
endfunction
Expand Down
2 changes: 0 additions & 2 deletions autoload/go/tool.vim
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,6 @@ function! s:balloon(msg)
if has('balloon_eval')
if has('balloon_multiline')
let l:msg = join(a:msg, "\n")
else
let l:msg = substitute(join(map(deepcopy(a:msg), 'substitute(v:val, "\t", "", "")'), '; '), '{;', '{', '')
endif
endif

Expand Down
11 changes: 9 additions & 2 deletions doc/vim-go.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1229,8 +1229,9 @@ Uses `gopls` for autocompletion. By default, it is hooked up to 'omnifunc'.

*go#tool#DescribeBalloon()*

Suitable to be used as an expression to show the evaluation balloon. See `help
balloonexpr`.
Suitable to be used as an expression to show the evaluation balloon. By
default only the type information is shown. |'g:go_doc_balloon'| can be used
to also included partial documentation. See `help balloonexpr`.

==============================================================================
SETTINGS *go-settings*
Expand Down Expand Up @@ -1450,6 +1451,12 @@ Maximum height for the GoDoc window created with |:GoDoc|. Default is 20. >

let g:go_doc_max_height = 20
<
*'g:go_doc_balloon'*

Show GoDoc in balloon. See |go#tool#DescribeBalloon()|. Default is disabled. >

let g:go_doc_balloon = 0
<

*'g:go_doc_url'*

Expand Down