go-plus
go-plus copied to clipboard
Show documentation in a tooltip as the user types
I propose that we should add support for cursor-following calltips when calling functions, like in vscode and Gogland:
The calltip follows the cursor as you type and if you start calling another function as a parameter to the first function (a nested function call) the tooltip updates with the documentation of the inner function you're calling.
Maybe we can reuse go-tip's box to some extent?
Or perhaps extend the lint tooltips if possible:
I'll try to implement something (might take a while because I'm not familiar with Atom internals) - @zmb3 has offered guidance, which is greatly appreciated.
My initial thought is to see how the 'statusbar function signature' works (how it gets the byte offset of where the cursor is right now and how it sends the unsaved file's buffer content to godoc's stdin) and use gogetdoc
to fetch the documentation that will output something like
{"name":"Int","import":"flag","decl":"func Int(name string, value int, usage string) *int","doc":"Int defines an int flag with specified name, default value, and usage string.\nThe return value is the address of an int variable that stores the value of the flag.\n","pos":"/usr/local/go/src/flag/flag.go:609:6"}
then build (or use some enhanced tooltip support that Atom hopefully already has) a tooltip (or toggle the visibility of a previously built tooltip) that follows the typing cursor and fills it with decl
and doc
.
As an extra, since we'll get the function and package name from gogetdoc, we could show a rendered godoc documentation on the side (using a godoc -http
server running locally) like that:
With the option to update the godoc page automatically as you type or only if you hit ALT+D or something.
Thoughts?
For reference: https://github.com/joefitzgerald/go-plus/issues/351#issuecomment-269795718
The doc panel links to godoc.org (09351e0c3a69418ebaa47951e4f3457b72ab337a), so let's scope this issue just to the tooltip.
I think this was implemented in https://github.com/joefitzgerald/go-plus/releases/tag/v6.0.0.
@rhcarvalho not quite - the tooltip you reference is when you hover the mouse over an identifier. This issue is asking for documentation while typing.