Add support for rust-script's in source file dependencies
Opened this issue · 2 comments
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:
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...)
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.
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.