dominikh / go-mode.el

Emacs mode for the Go programming language
BSD 3-Clause "New" or "Revised" License
1.38k stars 211 forks source link

godoc-gogetdoc not available in command list #360

Closed admacro closed 4 years ago

admacro commented 4 years ago

Hi, I discovered godoc-gogetdoc symbol today, but it's not in the M-x command list. How can I invoke it? (I've installed gogetdoc)

go-mode version: 20200425.1740 emacs version: "GNU Emacs 26.3 (build 1, x86_64-apple-darwin18.2.0, NS appkit-1671.20 Version 10.14.3 (Build 18D109)) of 2019-09-02"

muirdm commented 4 years ago

godoc-gogetdoc is not interactive, so you need to bind it to a key. You can also eval it directly (e.g. M-: "(godoc-gogetdoc)").

I recommend you look at gopls and lsp-mode. LSP supports viewing documentation among many other things.

psanford commented 4 years ago

The way its intended to be used is you set godoc-at-point-function to godoc-gogetdoc and then you call godoc-at-point to invoke it:

(defcustom godoc-at-point-function #'godoc-and-godef
  "Function to call to display the documentation for an
identifier at a given position.

This package provides two functions: `godoc-and-godef' uses a
combination of godef and godoc to find the documentation.  This
approach has several caveats.  See its documentation for more
information.  The second function, `godoc-gogetdoc' uses an
additional tool that correctly determines the documentation for
any identifier.  It provides better results than
`godoc-and-godef'."
  :type 'function
  :group 'godoc)
admacro commented 4 years ago

thank you @psanford, I got it working.

(setq godoc-at-point-function 'godoc-gogetdoc)

thanks @muirdm for the recommendation. I already use lsp-mode. I tried lsp-ui but it's a bit too much for me, as I only need to look up some doc on demand.