-
Notifications
You must be signed in to change notification settings - Fork 58
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
REPL: introduce a new jupyter notebook based REPL #1016
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is very cool. I've aded a few comments aimed at getting CI passing while I try it out more in depth.
@plemarquand anything to do here to move this along? |
@compnerd I did finally get a chance to try this out last week and found that the "Evaluate in REPL" functionality didn't work as I expected. Putting the cursor on If I write the same code out in the input window at the bottom of the notebook and execute it, it does get evaluated as I expect. I imagine there is work we could do here to hook everything up to the REPL hosted by the extension, but I think a better long term approach is to build a real Swift Jupyter kernel with something like xeus, likely as its own standalone repo, and then load in or depend on it in the VS Code extension. This would make it a "first class" experience that would be portable to other Jupyter environments. The Swift REPL could still power the kernel as you have it designed here. |
How can I add this to my VSCode? |
Here is how I just installed it. First, you have to pull this repository and switch to this PR's branch. Here is how you can do it:
Then make sure you have NPM and Node installed on your computer. If not, Google how to do it. To verify it's installed, run Install vsce, which is a command line tool for working with VSCode:
Then go to the root directory of this extension in the terminal and type
This is going to install all necessary packages for the extension build to be possible. Then if I got it correctly, you have to build it. Here is how you do it:
Then you have to package it into a VSCode extension (finally):
After it's packaged, it will output a directory with the extension. Now all you need to install it in the editor is to run this command, replacing the path to the extension you got from the previous command (I'd make sure it's not installed in VSCode before running the following command):
|
VSCode has introduced a native jupyter notebook API. Wire up a "kernel" for Swift to provide a native REPL experience within VSCode. This is primarily a PoC implementation that demonstrates how such an implementation could work. The primary limitation in the current implementation is the IO processing in the LLDB REPL. We can apply a heuristic to capture the error message (termination on an empty string), but do not have such a heuristic for the output and currently only capture the first line of the output, leaving the remaining output in the buffer. Improving the stream handling would significantly improve the experience. Co-authored-by: Jeremy Day <[email protected]>
Its been a while since I played with this, but I don't remember having to select a language. Can you refer to the Swift Forums post about this? This required experimental features in VSCode to enabled before it was usable. |
VSCode has introduced a native jupyter notebook API. Wire up a "kernel" for Swift to provide a native REPL experience within VSCode. This is primarily a PoC implementation that demonstrates how such an implementation could work.
The primary limitation in the current implementation is the IO processing in the LLDB REPL. We can apply a heuristic to capture the error message (termination on an empty string), but do not have such a heuristic for the output and currently only capture the first line of the output, leaving the remaining output in the buffer. Improving the stream handling would significantly improve the experience.