Description
I've been looking in to getting company-quickhelp working with Emacs / gocode / company-mode.
tl;dr: It doesn't work properly, because the output from gocode only includes the completion candidate, not the full context necessary to look up documentation. E.g., if I've typed "fmt.Spri", the completion candidate information is "Sprint", "Sprintf", "Sprintln", without the leading "fmt.". Without the package name, "go doc" doesn't find anything.
It does work for stuff that's within the same package though, which is something.
So it would be very helpful if the output from gocode included a field that could be reliably passed to "go doc".
Here's how to replicate what I've done so far.
Install gocode, company, and company-quickhelp (https://github.com/expez/company-quickhelp).
company-quickhelp / company interact with the doc-buffer
command passed to the company backend. company-go. This command should respond with a buffer that contains the help documentation.
gocode/emacs-company/company-go.el
doesn't do that yet, so edit company-go.el
as follows:
(defun company-go (command &optional arg &rest ignored)
(cl-case command
;; ...
(doc-buffer
;; arg is a string corresponding to the user's completion selection.
(godoc-as-buffer arg))
;; ...
...)
(defun godoc-as-buffer (query)
"Return Go documentation for QUERY as a buffer."
(unless (string= query "")
(let ((buf (godoc--get-buffer query)))
(call-process-shell-command (concat godoc-command " " query) nil buf nil)
buf)))
Eval both of those, open a .go file with go-mode, company and company-quickhelp enabled, and try some autocompletion in it.
If you leave an item in the menu of completion items that pops up selected for a second or so you should see a documentation popup appear. If it's something that "go doc" can find (e.g., a function in the same package that's got documentation) you should see the item's documentation. But if it's in another package "go doc" can't find it, so you get "doc: No symbol foo in package" as the documentation.
If gocode included a new field in the output that contained the full package name company-go.el could add that as a property that would be accessible within the doc-buffer command.