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: autocomplete for import #257

Closed
kokizzu opened this issue Nov 24, 2014 · 6 comments
Closed

Feature request: autocomplete for import #257

kokizzu opened this issue Nov 24, 2014 · 6 comments

Comments

@kokizzu
Copy link

kokizzu commented Nov 24, 2014

When typing inside import, there should be autocomplete containing all libraries that have been installed.

image

@nsf
Copy link
Owner

nsf commented Nov 24, 2014

Valid request, but since I'm in maintenance-only, I won't do it in near future. Maybe someone else will.

@myitcv
Copy link
Contributor

myitcv commented Nov 24, 2014

@kokizzu - if this is Vim, vim-go provides :GoImport which itself provides completion of imports.

@kokizzu
Copy link
Author

kokizzu commented Nov 24, 2014

ah this is LiteIDE, I will submit the feature request to LiteIDE.

@nhooyr
Copy link
Contributor

nhooyr commented Feb 13, 2016

I'm gonna take a stab at implementing this.

@nsf
Copy link
Owner

nsf commented Feb 13, 2016

Good luck, I would start from here: https://github.com/nsf/gocode/blob/master/cursorcontext.go#L272

You need to figure out somehow that the cursor is on the import clause. Maybe do some sort of reverse parsing. This function above actually does tokenize code, but you should take care about a common case when string literal isn't valid, e.g.:

package main
import (
  "io/
)

In this case tokenizer may actually fail. But there are hacks to avoid that, you can try detecting if amount of quotes before the cursor is odd (be careful about possible quotes in comments) and insert a quote after the cursor. All sorts of hacks may work. It's definitely possible to do a solid context detection here, but may take some time.

@nhooyr
Copy link
Contributor

nhooyr commented Feb 13, 2016

@nsf thanks.

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

No branches or pull requests

4 participants