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

Feature request: Offer declaration name as autocompletion when writing GoDoc comment #454

Open
atombender opened this issue May 31, 2017 · 5 comments

Comments

@atombender
Copy link

Consider that you're writing this in some editor:

package main

// Some<caret>
type Something struct {
  ...

The autocompletion at this point should offer Something as the top choice, since you're writing a GoDoc comment about this particular declaration. This ought to be the behaviour for any GoDoc comment.

@cznic
Copy link

cznic commented Jun 1, 2017

FTR: Ctrl-N in Vim.

@nsf
Copy link
Owner

nsf commented Jun 1, 2017

aaa

Gocode actually tries to perform autocompletion even if you are in a comment section. But many editors block autocompletion request in this scenario. If that's what you want, I can't help you, ask editor plugin authors. If you want some additional logic for entity comment specifically, not sure about that.

@atombender
Copy link
Author

VSCode does show completions, but it doesn't show the right completion. For example, if I have this:

type Something struct {}
type SomethingElse struct {}

// S<caret>
type SomethingElseEntirely struct {}

It would be greatly appreciated if the first completion offered is SomethingElseEntirely, not the other two. In fact, it's worse than that:

screen shot 2017-06-01 at 09 56 57

Even when I am more specific, the order is not helpful:

screen shot 2017-06-01 at 09 57 47

@nsf
Copy link
Owner

nsf commented Jun 1, 2017

Sorry I won't implement it. It's up to user what he puts in the comment. Having autocompletion like that would encourage stub comments (it's so easy to just press ctrl+space or whatever the key is). I think some of the go linters insist on comments like these - very bad idea.

Also what I see in your screenshots is generic plain text autocompletion by vscode, I assume it falls back to text autocompletion when you're in a comment. I think it's an okay idea to do so. But again, if you were using gocode here it would only suggest the actual language entites (types, vars, funcs, etc). Gocode is not responsible for all autocompletion in your editor, it only does Go code analysis, but often text editors mix in different completion providers like in this case. Autocompletion suggestions are marked with "abc" logo for a reason, it's a sign of plain text autocompletion. Gocode simply cannot do text-based autocompletions, there is no code which would lead to that kind of result.

@atombender
Copy link
Author

Sounds like VSCode should specifically have an autocompleter heuristic that looks if you're at the start of a GoDoc declaration comment, and if so, look for the next declaration. I don't know enough about VSCode's internals, nor about gocode, to say where the missing functionality needs to go.

Having autocompletion like that would encourage stub comments

I don't see why. The only point is to allow me to quickly complete the name of the thing I'm writing a comment for; the whole point of autocompletion is to automate work. It's my own responsibility to write a good comment.

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

3 participants