Skip to content
This repository has been archived by the owner on May 7, 2021. It is now read-only.

autocomplete unimported packages #685

Merged
merged 3 commits into from
Nov 16, 2017
Merged

Conversation

lloiser
Copy link
Collaborator

@lloiser lloiser commented Aug 30, 2017

This is done by (temporarily) adding an import "..." statement into the code so that gocode can find the package and provide suggestions for it.

It is still rough on the edges especially for vendored packages.

Possible improvements:

  • automatically add the import "..." when a suggestion is selected (nice to have, will be added by goimports on save anyway)
  • the pkg map in go.js does not grow if new packages are added (low prio)

Fixes #665

@zmb3
Copy link
Collaborator

zmb3 commented Aug 30, 2017

Have you considered gopkgs instead of go list? It reads $GOPATH/pkg instead of $GOPATH/src and is orders of magnitude faster.

@lloiser
Copy link
Collaborator Author

lloiser commented Aug 30, 2017

Nice! I will check it out.

@lloiser
Copy link
Collaborator Author

lloiser commented Sep 4, 2017

I choose gopkgs atm even though it does not resolve the actual package name but only the folder its in.
microsoft/vscode-go#647 shows that this can be an issue we will face sooner or later.

@lloiser lloiser changed the title WIP: autocomplete unimported packages autocomplete unimported packages Sep 5, 2017
This is done by adding an `import` statement for a package (provided by `gopkgs`) for `gocode` only
@lloiser lloiser force-pushed the ll-autocomplete-unimported branch from 8769f46 to c55853e Compare November 14, 2017 12:53
@lloiser
Copy link
Collaborator Author

lloiser commented Nov 14, 2017

@zmb3 or @joefitzgerald can anybody pls review this 😁

Copy link
Collaborator

@zmb3 zmb3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a spec with a fixture that doesn't import a package to actually flesh this out?

lib/go.js Outdated
'use babel'

let goVersion
export function version (goconfig) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks pretty similar to the locator code. Can we reuse any of that? Are we duplicating work here?

@joefitzgerald joefitzgerald merged commit c4744a0 into master Nov 16, 2017
@joefitzgerald joefitzgerald deleted the ll-autocomplete-unimported branch November 16, 2017 05:44
@joefitzgerald
Copy link
Owner

Thanks @lloiser!!

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

Successfully merging this pull request may close these issues.

3 participants