Skip to content
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

Add support for rust-script's in source file dependencies #111

Open
Andrew15-5 opened this issue Mar 8, 2024 · 2 comments
Open

Add support for rust-script's in source file dependencies #111

Andrew15-5 opened this issue Mar 8, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@Andrew15-5
Copy link

Hello. I recently found out about https://rust-script.org/, which sounds like a great substitution for shell/python scripts that I have a ton of. I made my first Rust script a few days ago and it is awesome. The problem is that rust-analyzer only works with cargo projects and doesn't help when a single-file project is opened. But another issue is that to make the script "portable" you have to include dependencies in the Rust file:

image

And I was wondering if it will be possible to make this plugin work with this embedded version of Cargo.toml's dependencies. I have to modify dependencies in the Cargo.toml first and then copy/sync them with the rust-script's place for those dependencies. If this plugin can work right in the Rust file, then I would only have to open a single file, which makes the workflow much simpler and quicker. (Though for rust-analyzer to work, I would still have to modify Cargo.toml...oh well...)

@saecki
Copy link
Owner

saecki commented Mar 8, 2024

Afaik rust-analyzer already has support for standalone files: rust-lang/rust-analyzer#8955.

As for crates.nvim it should be possible, but will be a decent amount of work. I'm currently debating whether to rewrite this whole plugin in rust or using https://github.com/saecki/crates-nvim-rs just as the toml parser. Until then it's unlikely though not impossible that I will implement this feature.

@Andrew15-5
Copy link
Author

Afaik rust-analyzer already has support for standalone files: rust-lang/rust-analyzer#8955.

Ok, but apparently it doesn't just work out of the box. But I made a snippet that pretty much does just that: mrcjkb/rustaceanvim#253 (reply in thread).

But it only works with the standard Rust and is still useless for when using the third-party libraries. Although, if there is no Cargo.toml to check the dependencies from, how would it know which libraries to load. Would be cool if rust-analyzer can read the rust-scripts's in source file dependencies. Then all the problems would be solved.

Until then it's unlikely though not impossible that I will implement this feature.

Sure. No rush.

@saecki saecki added the enhancement New feature or request label May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants