-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Feature request: Intellisense in Jupyter cells #9343
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
Comments
I was recently trying to figure this out, and ran into a bit of a problem because there seems to be a difference between normal Rust code and In fn five() -> i32 {
5
}
five() If you run this in Moreover, I'm contemplating two solutions to this, and would love to get some feedback on what would be best.
CC @davidlattimore who indicated some interest over in #5141 :) |
Can it be wrapped in a function like this: fn f() -> ! {
fn five() -> i32 {
5
}
five()
} |
Hmm, I just tried that in a simple Rust project and
I'm far from a Rust expert though so could easily be missing something. fn five() -> i32 {
5
}
five()
println!("hello");
five() |
Given the final expression is to be printed anyways the wrapping could always be something like fn main() {
let eval = {
// cell content goes here
};
println!("{eval}");
} or whatever the desired way to handle this is. I don't know how evcxr works. Note though that any modifications for this to the |
Oops, I misspoke earlier when I said the semicolon-free statements could appear anywhere. They can only appear as the final statement in a cell. That seems to work, thanks @Veykril! I'll run with this and report back if any other problems come up... |
Since the previous related issue that was linked above (3+ years ago), evcxr now uses rust-analyzer internally in order to figure out variables types, provide autocomplete and probably some other things I've forgotten. I think in order to wrap the code in a way that would work consistently with what evcxr is doing, you'd probably need to actually call into evcxr. There's quite a bit of complexity in turning the code that the user supplies into the code that's given to rustc or rust-analyzer. For example, if you've already run some notebook cells, then there might be variables defined. Those variables need to still be defined in later cells and have their correct types. But I have no idea how you would cleanly call into evcxr to get the wrapped code to analyze. Even if you could get the wrapped code, you still need to do the reverse - e.g. when an error is reported in the wrapped code, the span information needs to be mapped back to the original code. Evcxr does this internally, but I'm not sure how it would be done externally. If you use Evcxr from a Jupyter Notebook in a web browser, then tab completion works and you also get red and yellow squigglies with hovers for errors and warnings. It's not everything that you would get editing regular rust code in vscode with rust-analyzer, but it's something. I suspect if you want nice rust-analyzer based vscode evcxr integration, the best path is perhaps to write/edit/extend a vscode extension that calls through to the evcxr jupyter kernel, then leverage the copy of rust-analyzer built into evcxr to get whatever info you need. I'm not at all familiar with the state of Jupyter integration in vscode, so I don't know whether it would be best to extend an existing Jupyter Notebook extension or build something more from scratch. |
I would like to know the current situation of supporting, and there is any progress? |
There are no plans to implement this from our side in the foreseeable future if at all. |
Hi, I'm writing a notebook using Rust with Jupyter and I want to use rust-analyzer to get intellisense in my rust cells. I'm using the VSCode extension for Jupyter. Do you think this could be implemented? Thanks.
The text was updated successfully, but these errors were encountered: