-
-
Notifications
You must be signed in to change notification settings - Fork 28
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
Add import completion #32
Comments
This is more of an issue with gocode. Also vim-go has the |
@nhooyr |
It would make much more sense to let gocode handle it than do it ourselves. |
@dobegor what do you mean it isn't useful? it works perfectly fine for me. |
@dobegor @nhooyr Hi, However, see #19 It is possible to display the package name if current input is I think maybe performance reduced, but will not significantly affect because statically cache. WDYT? |
@dobegor @nhooyr or, If current input is It 's sorry. |
@zchee looks great, good morning then :) |
@dobegor At first, I wrote the details of the flow. |
@dobegor At second, sloppy but... def gather_candidates(self, context):
buf = self.vim.current.buffer
pkgs = self.GetCurrentImportPackages(buf)
parent = str(context['input']).strip('\t')
pkg_data = os.path.join(self.data_directory, parent + 'json')
if parent not in pkgs and '.' in parent and os.path.isfile(pkg_data):
with open(pkg_data) as json_pkg_data:
result = loads(json_pkg_data.read())
elif re.match(r'^\s*import \w*', parent):
# packages.json is https://gist.github.com/zchee/bdfe8b1967d3f958caee
with open(os.path.join(self.data_directory,
'packages.json')) as json_pkg_data:
result = loads(json_pkg_data.read())
else:
line = self.vim.current.window.cursor[0]
column = context['complete_position']
offset = self.vim.call('line2byte', line) + \
charpos2bytepos(self.vim, context['input'][: column],
column) - 1
source = '\n'.join(buf).encode()
.
.
. Currently, conditions only self.GetCurrentImportPackages(buf, resultIsPackageNameOrJsonData?) |
@zchee i really think we shouldn't bother, much rather let gocode. Its not really a urgent feature, goimports works perfectly fine. Its autocomplete is nice. If you really want to, go ahead, there is no real harm. It might add some needless complexity though. |
@zchee so this will only allow to auto-complete a fixed set of import paths? I have literally 2 days experience with Vim, but I can certainly write such utility in Golang (using third-party lib for fast fuzzy matching). |
@dobegor why don't you just modify |
Now, If you said implements are realized, and faster than I'm sorry if my understanding is wrong. |
@zchee I'm gonna take a stab at implementing it in gocode. I'll update once I have it done. |
@nhooyr I looking forward update. |
@nhooyr Thanks! |
Once its merged (likely tomorrow) we just need to update our regex for completion in strings, as well as add a new class import. Thats it. |
@nhooyr I got it. |
Its been merged! |
@nhooyr Yeah!!!!
I would like to confirm, but it meaning is |
yes. |
@nhooyr OK. I will update the input pattern corresponding to it. (Maybe tomorrow...) |
@zchee https://asciinema.org/a/3xz29k70w2zmi27sg2zugde74 just a slight problem. |
@nhooyr Oh, Good catch. Thanks. Actually, it seemed necessary fixes for |
@nhooyr |
@zchee its the same, |
I wish there was import completion like in LiteIDE.
I.e. you typed:
and it offers
fmt
package to import.The text was updated successfully, but these errors were encountered: