zed-industries / zed

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
https://zed.dev
Other
39.77k stars 2.08k forks source link

Configure rust toolchain on a per-folder/project level #4883

Open dcow opened 1 year ago

dcow commented 1 year ago

Check for existing issues

Describe the feature

I have a few different rust projects. Some use nightly rust, some user normal rust, one even uses a custom toolchain.

I'd like to be able to instruct Zed to use the appropriate toolchain at a project level and have all downstream commands be modified to use the correct toolchain (clippy, fmt, rust-analyzer, etc).

A global config option would be a start, but I suspect very quickly users would find themselves changing the setting when opening different folders/projects. And what if you have two zeds open at once? So I think a project-level option is appropriate.

If applicable, add mockups / screenshots to help present your vision of the feature

No response

JosephTLyons commented 1 year ago

Hey @dcow, I think the generic need here might be project-specific settings:

Then for those project-specific settings to support changing settings related to the rust toolchain. Would you mind upvoting the linked issue with a 👍?

dcow commented 1 year ago

Done!

bazhenov commented 1 year ago

To anyone who is interested in using nightly for a specific project I would recommend following solution. Create file rust-toolchain.toml in the project directory with following content:

[toolchain]
channel = "nightly"

More about toolchain overrides in the documentation. Tested on the Zed/0.86.1

Although not the full solution for described problem, it works for using nightly

dcow commented 1 year ago

I actually think it's preferable to use this toolchain file approach in most all cases I can think of save a scenario where zed specifically needs to use a bespoke toolchain for some reason.

darrell-roberts commented 3 months ago

Using rust-toolchain.toml won't help in my case from what I read. Between projects I have different settings for rust-analyzer.cargo.features and rust-analyzer.files.excludeDirs. I have to comment out the global settings each time I switch, preventing me from working on multiple projects simultaneously. A configuration per workspace would be best.