-
Notifications
You must be signed in to change notification settings - Fork 47
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
Completion not working in hy-mode #93
Comments
From what I can discern, I think when hy mode constructs the jedhy instance its making the call to I don't know how to fix it yet, but maybe this will help |
That sounds plausible, will give it a run |
so did some more digging and I don't know if we can get local var completions without running jedhy in the user's shell. Jedi gets around it be doing some crazy static code analysis, but jedhy is just doing a |
It doesn't use the regular shell because of eg. long running computations and polluting completions with variables you set in the shell. We get some of the way there by providing a command to send the imports in the current file (identified by a regex elisp side). This resolves completions for big imports like numpy and pandas. If you look at the regex it also sends sys.path extensions. This can be used to accomplish local completions in effect. (Eg. Use 'import * from myfile'). I used this when I was still working actively with hy. It is not perfect or even a good solution but it was effective for me compared to the alternative at the time (hy-mode/tooling was basically nothing). |
I'd be OK if jedhy ran in my user shell. Let me know if you have some ideas I can try on my end (simply changing the buffer doesn't do it.) |
In theory I don't see anything stopping Hy from substituting the python AST it constructs directly into jedi or a python LSP implementation. Then we could access Python's tooling - save for Hy's unique constructs like macros. It certainly is in-line with what I see attractive about Hy (that it interops with python's ecosystem). This would be quite involved though.
The internal shell is also technically a user shell. In particular you could type If updating
Note that 1 and 3 can be utilized together - and is what I've done in the past. |
Feeding the generated ast directly into Jedi world be extremely cool, and pretty in line with the whole python interop philosophy. I don't know if it would be possible though as an incomplete attribute access |
This is honestly such a dumb solution but it works for some reason and I find it hilarious that it does. (setv source "
(setv something [1 2 3 4])
(print (something.))
"
cursor-line 3
cursor-column 18)
(lfor completion (complete source cursor-line cursor-column)
completion.name)
;; => ['append', 'clear', 'copy', 'count', 'extend', ... ] (setv source "
(import json)
(json.lo)
"
cursor-line 3
cursor-column 8)
(lfor completion (complete source cursor-line cursor-column)
completion.name)
;; => ['load', 'loads'] Basically, i'm using You can find the gist here: https://gist.github.com/allison-casey/33da1d7777bc7727a3140b7d328d7ebb |
That's pretty freaking clever @allison-casey!! |
+1 here! Feel free to reach out over anything. |
Hy version: 0.18.0
The following code does not seem to complete in
hy-mode
. I do have completion for builtins and as you can see, it does work with jedhy directly. I'd love to debug so if you can give some tips on where to start, that would be great.The text was updated successfully, but these errors were encountered: