-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Added project-specific Zed IDE settings #127793
base: master
Are you sure you want to change the base?
Conversation
r? @nnethercote rustbot has assigned @nnethercote. Use |
Some changes occurred in compiler/rustc_codegen_cranelift cc @bjorn3 |
I don't think this repo has a top-level |
This comment has been minimized.
This comment has been minimized.
I don't know much about IDEs, but @tgross35's suggestion about generating the Zed settings seems reasonable. |
As @tgross35 said, for this repo, |
OK, I'll examine |
@bjorn3 said:
Made |
This PR modifies If appropriate, please update |
This comment has been minimized.
This comment has been minimized.
src/etc/zed_settings.json
Outdated
@@ -0,0 +1,48 @@ | |||
{ | |||
// The following commented-out VS Code settings are not supported by Zed yet. | |||
// "git.detectSubmodulesLimit": 20 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This option was introduced for vscode in #120138. There is a fair chance that zed won't suffer from the same issue once it has a git ui anyway (they may not even add a hard limit on the amount of auto detected git submodules at all). I don't think there is any value in keeping this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It could be nicer to still keep one file for RA settings, then just delete this key via bootstrap (serde_json is already a dependency). So if there are future updates that work for both, they only need to happen in one file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In order to do this properly, I think we'll need three files: one shared file for rust-analyzer
settings and one file each for the non-rust-analyzer
IDE-specific settings.
Even IDE settings that do the same thing are different between the two IDEs. For example, to turn on format-on-save, VS Code wants "editor.formatOnSave": true,
while Zed wants "format_on_save": "on",
.
There are also JSON structure requirements that differ between the IDEs. For example, VS Code wants the rust-analyzer
settings to use the standard dotted notation at the root of the JSON tree, like:
{
"rust-analyzer.rustc.source": "discover"
}
Zed wants the rust-analyzer
settings to live under a path through the JSON tree of "lsp"
, then "rust-analyzer"
, then "initialization_options"
, then the setting with the original dots signifying an increase in tree depth:
{
"lsp": {
"rust-analyzer": {
"initialization_options": {
"rustc": {
"source": "discover"
}
}
}
}
}
So this means that we need to do JSON parsing of our three files, transformation of the structure, and JSON generation of the resulting .vscode/settings.json
and .zed/settings.json
files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could also just have one rust source file with everything in json!
, and build it dynamically
use serde_json::{json, Value};
fn base_settings() -> Value {
json! {{
// common settings
}}
}
fn vscode_settings() -> Value {
let vscode_specific = json! {{ anything new}}
let mut inner = base_settings();
inner.as_object_mut().unwrap().extend(vscode_specific);
json! {{
"lsp": {
"rust_analyzer": /* other nesting */ inner,
}
}}
}
fn zed_settings() -> Value {
// ...
}
Which would also be kind of nice because it's easy to cover any config file schema or format. E.g. I would appreciate a Helix config at some point, but that uses toml (easy to convert from serde_json
to toml
, both are already dependencies of bootstrap).
But 🤷, that may be overkill.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bjorn3 Removed comment in Zed settings.json
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tgross35 It looks like they've added some settings for a few more IDEs in the meantime (Emacs, Helix, and Vim/VS Code), but they put all the settings into each one.
|
||
/// Create a `.zed/settings.json` file for rustc development, or just print it | ||
/// If this method should be re-called, it returns `false`. | ||
fn create_zed_settings_maybe(config: &Config) -> io::Result<bool> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this function be deduplicated with the vscode version?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bjorn3 It seems to have been deduplicated in the meantime.
Should probably just see what bootstrap prefers here r? bootstrap |
Can Zed work with the VsCode configuration file somehow (like neovim)? FWIW #120611 would solve the whole problem of maintaining IDE specific files. |
Seems like we will also need rust-lang/rust-analyzer#13529 for that. |
☔ The latest upstream changes (presumably #130091) made this pull request unmergeable. Please resolve the merge conflicts. |
Okay well we added emacs and helix sample config files, so maybe just adding the zed file is fine here too :) #130932 |
FYI, we now have a dedicated |
@ChaiTRex any updates on this pr? thanks |
* Order IDEs alphabetically so that manually searching for an IDE is easier, both when running `./x setup` and when editing the source code behind `./x setup` * Prepare for IDEs with spaces in their names * Allow explicitly typing 'none' for the IDE * Change capitalization of `Vscode` to the more standard `VsCode` * Make minor efficiency improvements * Add `'static` annotations where they apply
c1c7d6e
to
3422218
Compare
3422218
to
d9f125d
Compare
This comment has been minimized.
This comment has been minimized.
@Dylan-DPC Sorry for the delay. I've rebased this on the new multi-IDE system we now have and made a few minor improvements, like double-checking the latest hashes for all IDEs rather than just VS Code, which caught a missing Helix hash. |
Thanks! Could you also please add a mention of Zed to the suggested workflow page in rustc-dev-guide (https://github.com/rust-lang/rust/blob/fd911ea65a50c838f4334ef353c80ec46358c9e6/src/doc/rustc-dev-guide/src/building/suggested.md#helix)? You can do it directly with a commit in this PR, as rustc-dev-guide is now a subtree of rust-lang/rust. |
The rustc-dev-guide subtree was changed. If this PR only touches the dev guide consider submitting a PR directly to rust-lang/rustc-dev-guide otherwise thank you for updating the dev guide with your changes. |
8131d95
to
cd278aa
Compare
cd278aa
to
410331c
Compare
@Kobzol Done. Please let me know if it needs improvement. |
Thanks! @bors r+ rollup |
Added project-specific Zed IDE settings This repository currently has project-specific VS Code IDE settings in `.vscode` and `compiler/rustc_codegen_cranelift/.vscode`. Now there are equivalent project-specific Zed IDE settings alongside those. This fixes `rust-analyzer` not being able to properly handle this project. Note that: 1. The contents of `src/tools/rust-analyzer/.vscode` could not be translated to Zed, as they aren't basic IDE settings. 2. One of the VS Code settings in `.vscode` has no corresponding setting in Zed, and so this has been noted like this: ```json "_settings_only_in_vs_code_not_yet_in_zed": { "git.detectSubmodulesLimit": 20 }, ```
…llaumeGomez Rollup of 11 pull requests Successful merges: - rust-lang#127793 (Added project-specific Zed IDE settings) - rust-lang#134995 (Stabilize const_slice_flatten) - rust-lang#135767 (Future incompatibility warning `unsupported_fn_ptr_calling_conventions`: Also warn in dependencies) - rust-lang#136599 (librustdoc: more usages of `Joined::joined`) - rust-lang#136750 (Make ub_check message clear that it's not an assert) - rust-lang#137000 (Deeply normalize item bounds in new solver) - rust-lang#137126 (fix docs for inherent str constructors) - rust-lang#137151 (Install more signal stack trace handlers) - rust-lang#137161 (Pattern Migration 2024: fix incorrect messages/suggestions when errors arise in macro expansions) - rust-lang#137167 (tests: Also gate `f16::erfc()` doctest with `reliable_f16_math` cfg) - rust-lang#137177 (Update `minifier-rs` version to `0.3.5`) r? `@ghost` `@rustbot` modify labels: rollup
Added project-specific Zed IDE settings This repository currently has project-specific VS Code IDE settings in `.vscode` and `compiler/rustc_codegen_cranelift/.vscode`. Now there are equivalent project-specific Zed IDE settings alongside those. This fixes `rust-analyzer` not being able to properly handle this project. Note that: 1. The contents of `src/tools/rust-analyzer/.vscode` could not be translated to Zed, as they aren't basic IDE settings. 2. One of the VS Code settings in `.vscode` has no corresponding setting in Zed, and so this has been noted like this: ```json "_settings_only_in_vs_code_not_yet_in_zed": { "git.detectSubmodulesLimit": 20 }, ```
Added project-specific Zed IDE settings This repository currently has project-specific VS Code IDE settings in `.vscode` and `compiler/rustc_codegen_cranelift/.vscode`. Now there are equivalent project-specific Zed IDE settings alongside those. This fixes `rust-analyzer` not being able to properly handle this project. Note that: 1. The contents of `src/tools/rust-analyzer/.vscode` could not be translated to Zed, as they aren't basic IDE settings. 2. One of the VS Code settings in `.vscode` has no corresponding setting in Zed, and so this has been noted like this: ```json "_settings_only_in_vs_code_not_yet_in_zed": { "git.detectSubmodulesLimit": 20 }, ```
Added project-specific Zed IDE settings This repository currently has project-specific VS Code IDE settings in `.vscode` and `compiler/rustc_codegen_cranelift/.vscode`. Now there are equivalent project-specific Zed IDE settings alongside those. This fixes `rust-analyzer` not being able to properly handle this project. Note that: 1. The contents of `src/tools/rust-analyzer/.vscode` could not be translated to Zed, as they aren't basic IDE settings. 2. One of the VS Code settings in `.vscode` has no corresponding setting in Zed, and so this has been noted like this: ```json "_settings_only_in_vs_code_not_yet_in_zed": { "git.detectSubmodulesLimit": 20 }, ```
This repository currently has project-specific VS Code IDE settings in
.vscode
andcompiler/rustc_codegen_cranelift/.vscode
. Now there are equivalent project-specific Zed IDE settings alongside those.This fixes
rust-analyzer
not being able to properly handle this project.Note that:
The contents of
src/tools/rust-analyzer/.vscode
could not be translated to Zed, as they aren't basic IDE settings.One of the VS Code settings in
.vscode
has no corresponding setting in Zed, and so this has been noted like this: