Add rust target selector
Describe the feature
Add a rust target selector to make it possible to develop multi-platform projects with Zed. It would be enough to add a list in JSON and then have a popup list in the UI, i.e:
"targets": [
"aarch64-apple-ios",
// etc...
]
Then re-run rust-analyzer on change.
Zed Version and System Specs
Zed: v0.167.1 (Zed) OS: macOS 14.7.0 Memory: 36 GiB Architecture: aarch64
Interesting idea! I've wanted this when trying to troubleshoot/change behavior for Linux while developing on Mac.
As a workaround you should be able to add the following in your zed settings.json:
"lsp": {
"rust-analyzer": {
"initialization_options": {
"cargo": {
// "target": "x86_64-unknown-linux-gnu"
// "target": "x86_64-pc-windows-msvc"
// "target": "aarch64-apple-darwin"
}
}
}
}
Then you can uncomment one line if you need to have RA use a specific target triple. You can also include this in a .zed/settings.json inside your project folder if you always want a specific target (e.g. "aarch64-apple-ios") for a given project.
It's worth noting that rust-analyzer currently doesn't have a way of changing the active cfg, so updating the setting like that and restarting the server is the only way to change cfgs. See rust-lang/rust-analyzer#6117 and rust-lang/rust-analyzer#16346 (meta tracking issue) for the progress on that effort.
If they do grow that functionality we'd totally want to expose it in zed, but right now any "pick a different target" action would have to go modify your settings and restart rust-analyzer itself which I'm not sure we want.
It's worth noting that rust-analyzer currently doesn't have a way of changing the active cfg, so updating the setting like that and restarting the server is the only way to change cfgs. See rust-lang/rust-analyzer#6117 and rust-lang/rust-analyzer#16346 (meta tracking issue) for the progress on that effort.
Correct, but is it a bad thing?
FYI this is how it works in VSCode.
Hi there! 👋 We're working to clean up our issue tracker by closing older bugs that might not be relevant anymore. If you are able to reproduce this issue in the latest version of Zed, please let us know by commenting on this issue, and it will be kept open. If you can't reproduce it, feel free to close the issue yourself. Otherwise, it will close automatically in 14 days. Thanks for your help!