-
Notifications
You must be signed in to change notification settings - Fork 45
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
IDE support #11
Comments
Going to be challenging, but leaving this open for ideas and discussion! |
I think the issue with rust-analyser would need to be done within rust-analyser maybe by handling .ers files specially (since I think that's an extension rust-script can use for scripts by association) I had a quick look at how debugging might work (such as breakpoints)
The debugger extension would need to run something like the below but automatically switch out the program field with the output from rust-script and also maybe add in a sourceMap entry to map the original source script to the one in the build directory
|
I was looking into this literally this evening, and it looks to me like the easiest way to start is by forking rust-analyzer and implementing some changes without significant regard for existing features. I believe this could reach proof of concept quite rapidly. Then, once the fork works, one can think about how and whether integration into rust-analyzer itself might be done. (Given how the suggestion to support individual rs files was received in rust-lang/rust-analyzer#4477, I'm unsure as to whether they would be receptive to the idea. On the other hand, I've added the proof of concept project near the top of my large pile of project ideas. If I get around to trying it, I'll report back. |
I am making progress on this. I will share when I have something to show. |
@SafariMonkey Anything to show yet? I think there are a few things to talk about, detection and IDE support Detectionthe way I see it there are two possible methods
IDEObviously supporting the majority of these platforms is silly for our small project, so I crossed out most things that we probably should not focus any effort on. that leaves
As plausible candidates. I feel drawn to VScode as a user of it, so thats my vote for the first focus |
I have spent a decent amount of time on this, with various branches, ending in byte-accurate tracking of the location of the span of the cargo manifest, which I have succeeded in feeding into The best I've come up with is to represent the script as a pseudo-macro that is invoked from the generated path, which generates the code, or possibly representing the source file as a custom source code path (
(source) Overall, this project has been on my mind I haven't touched the code since late March now because I've been unable to find the best approach, nor to formulate my thoughts in a constructive way to ask e.g. the I welcome any thoughts and feedback on how to proceed. |
Helpwanted |
Hello there , here this library gives some insights about how and why rust-analyzer not working and workaround ways and here this library fixes auto-completion, but not code check on the fly , reminder the library expects rust files under "exercises" folder in the end for me as a rust learner the most practical way is building a cargo package and then creating a folder named "examples" which cargo does not complain having multiple separated rust files, and everything works perfectly , You can run individual executable examples with the cargo run command with the --example option , but more easy way is in vs-code installing code runner then defining "rust-script" as run command , then you don't have to worry about the ".exe" output everything is clean and fast, works perfect |
It seems to me that forking Let me suggest a perhaps more pragmatic workaround:
Based on this, here's what I envision:
This way at least |
To add to that, once such support is available in |
Yet another approach would be to create a language server that proxies almost all requests/response to/from |
Any updates on this? |
Here's a proof-of-concept of what I said in the last comment. It kinda works at some extent, but haven't tested extensively. |
@MiSawa Great suggestion! Should be fixed by the just released 0.25.0 version of rust-script. |
Ah nice, thank you for the quick fix! |
So... here's a script that generates What I learned about
|
@MiSawa Nice work - #103 has just been released in version 0.28.0. Perhaps we should move towards this setup where the source input file is unmodified always, and deprecate (or at least avoid encouraging it in the the documentation) functionality such as automatically wrapping the script with a |
Thank you, released rscls 0.2.0 that works well with rust-script Hmmm, I personally always use scripts including |
+1 @MiSawa to |
Is there a known way for something like rust-analyzer to work on these scripts? I think if I add a Cargo.toml with all the crates I use in my scripts, I might be able to get some support.
However, that won't work with the special template syntax.
Any tips regarding using IDEs with rust-script? I believe cargo-eval and cargo-script suffer from the same issues.
The text was updated successfully, but these errors were encountered: