-
Notifications
You must be signed in to change notification settings - Fork 95
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: provide code completion #21
Comments
I agree it would be very useful :) The same feature has bee requested and discussed in gophernotes, a Jupyter kernel for Go that uses gomacro - see gopherdata/gophernotes#22 In alternative, I thought about using https://github.com/nsf/gocode and, while somewhat easier, it's not completely trivial (requires writing interpreted code to files) and introduces a significant dependency. Suggestions are welcome :) |
What about running the gomacro interpreter and using the reflect package? For instance, if we have:
then evaluating I guess there is the special case of package for which this method would not work. But then perhaps global names would be more appropriate for that case and for global variables in general. |
Yes, looking up fields and methods of an existing variable is relatively straightforward (it's only slightly more complicated than your example code because methods of interpreted types are emulated). And looking up symbols of imported packages is straightforward too. Maybe that's already enough to be useful... the missing part would be completion of local variables' fields and methods, as for example:
Where the input source is not yet complete (parenthesis and braces are not balanced) and the user hit TAB at the The only solution I am aware of is to parse the code in a new context (to avoid completion side effects as defining new types, functions, methods...) with an error-resistant parser and type checker - but gomacro currently has neither of them |
Python code completion in ipython or jupyter only provides what you describe as 'straightforward' and it is already super useful. Can the work done for gophernotes/issues/22 be reused for the terminal prompt? |
You're talking about @jpark-dev comment gopherdata/gophernotes#22 (comment) and his patch, right? |
Done :) Feedback is welcome :) |
It is brilliant. I am already wondering how I was doing before! Thank you very much. |
Ideally, there would be a function available on
fast.Interp
like:Complete(prefix string) []string
which would return the list of possible completions. It seems that such list could be returned to liner using
line.SetCompleter
to improve the REPL provided in gomacro.The text was updated successfully, but these errors were encountered: