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

Make vim-go respect g:go_doc_command #1370

Closed
aktau opened this issue Jul 23, 2017 · 9 comments
Closed

Make vim-go respect g:go_doc_command #1370

aktau opened this issue Jul 23, 2017 · 9 comments

Comments

@aktau
Copy link

aktau commented Jul 23, 2017

Behavior

When using :GoDoc (or similar functionality), the godoc program is used, even when altering g:go_doc_command to say go doc.

Steps to reproduce:

Load vim-go and use this option

let g:go_doc_command = 'go doc'

I suspect the reason for this is that g:go_doc_command is only documented, never used:

$ rg go_doc_command
autoload/go/doc.vim
7:if !exists("g:go_doc_command")
8:  let g:go_doc_command = "godoc"

doc/vim-go.txt
1186:                                                          *'g:go_doc_command'*
1191:  let g:go_doc_command = "godoc"
1195:Use this option to add additional options to the |'g:go_doc_command'|. Default

Configuration

I do not believe specific verison of Vim and such are important here. I used execsnoop(1) to see that godoc was being called, not go doc.

@arp242
Copy link
Contributor

arp242 commented Jul 23, 2017

You're right; g:go_doc_command is only mentioned in the documentation, it's never referenced.

Note that godoc is only used when :GoDoc has an argument, e.g. :GoDoc fmt. If you use just :GoDoc to get the documentation under the cursor then gogetdoc is used.

Personally I'm not sure if it's worth even having this option? What advantage does go doc have over godoc?

@aktau
Copy link
Author

aktau commented Jul 24, 2017

Note that godoc is only used when :GoDoc has an argument, e.g. :GoDoc fmt. If you use just :GoDoc to get the documentation under the cursor then gogetdoc is used.

Interesting, thanks for clarifying. I guess that should also be documented then, for hapless souls who are trying to change the command.

Maybe it would be best to separate the tasks of the tools a bit better, gogetdoc seems to analyze the current file for the package + name of the identifier at $pos, and then defer to the go/doc package which I assume go doc also uses. If there were a goidentify, it could just return $package.$name for the position and that could be forwarded to other tools.

Anyway, I happen to not have gogetdoc installed, and the only error I ever saw was:

-1

Which I'm betting comes from

return -1
.

Perhaps it could say something like: please install gogetdoc?

@arp242
Copy link
Contributor

arp242 commented Jul 24, 2017

Anyway, I happen to not have gogetdoc installed, and the only error I ever saw was:

-1

Perhaps it could say something like: please install gogetdoc?

The new window with -1 is a bug, I made PR to fix that.

You should actually get an error too in the statusline though:

2017-07-24-110507_834x175_scrot

@fatih
Copy link
Owner

fatih commented Jul 24, 2017

Fixed with #1379

@fatih fatih closed this as completed Jul 24, 2017
@aktau
Copy link
Author

aktau commented Jul 24, 2017

Thanks! At least that gets rid of the cryptic -1 :).

@citrin
Copy link

citrin commented Aug 9, 2017

Why this bug was closed? It still not possible to write let g:go_doc_command = 'go doc' in ~/.vimrc
Either code or documentation (if command is not configurable) should be changed.

@arp242
Copy link
Contributor

arp242 commented Aug 9, 2017

I guess because the -1 thing is fixed?

The problem here is that setting let g:go_doc_command = 'go doc' won't work, even if this was implemented since vim-go will try to execute go doc as the binary name (instead of go with doc as an argument).

So it should be a list: ['go', 'doc'], but this makes it inconsistent with how other *_command settings work :-/

I've been planning to look at this, since I believe there are some other commands that also need some attention, but I also broke my arm last week unfortunately so my plans are a bit on hold atm.

In the meanwhile, you could run go doc by creating a godoc wrapper script and putting that somewhere in your PATH before the "real" godoc (you can modify $PATH in an autocmd).

@citrin
Copy link

citrin commented Aug 10, 2017

Thanks for clarification.

@dougblack
Copy link

Personally I'm not sure if it's worth even having this option? What advantage does go doc have over godoc?

For what it's worth, go doc seems to do a better job resolving ambiguous package names than godoc:

$ go doc json
package json // import "encoding/json"

Package json implements encoding and decoding of JSON as defined in RFC
4627. The mapping between JSON and Go values is described in the
documentation for the Marshal and Unmarshal functions.
[...]
$ godoc json
2018/01/04 10:03:23 cannot find package "." in:
        /src/json

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants