aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/rust-analyzer/src/config.rs39
1 files changed, 28 insertions, 11 deletions
diff --git a/crates/rust-analyzer/src/config.rs b/crates/rust-analyzer/src/config.rs
index 247bfe71e..071fde64d 100644
--- a/crates/rust-analyzer/src/config.rs
+++ b/crates/rust-analyzer/src/config.rs
@@ -39,7 +39,7 @@ config_data! {
39 /// Automatically refresh project info via `cargo metadata` on 39 /// Automatically refresh project info via `cargo metadata` on
40 /// `Cargo.toml` changes. 40 /// `Cargo.toml` changes.
41 cargo_autoreload: bool = "true", 41 cargo_autoreload: bool = "true",
42 /// Activate all available features. 42 /// Activate all available features (`--all-features`).
43 cargo_allFeatures: bool = "false", 43 cargo_allFeatures: bool = "false",
44 /// List of features to activate. 44 /// List of features to activate.
45 cargo_features: Vec<String> = "[]", 45 cargo_features: Vec<String> = "[]",
@@ -55,10 +55,10 @@ config_data! {
55 55
56 /// Run specified `cargo check` command for diagnostics on save. 56 /// Run specified `cargo check` command for diagnostics on save.
57 checkOnSave_enable: bool = "true", 57 checkOnSave_enable: bool = "true",
58 /// Check with all features (will be passed as `--all-features`). 58 /// Check with all features (`--all-features`).
59 /// Defaults to `#rust-analyzer.cargo.allFeatures#`. 59 /// Defaults to `#rust-analyzer.cargo.allFeatures#`.
60 checkOnSave_allFeatures: Option<bool> = "null", 60 checkOnSave_allFeatures: Option<bool> = "null",
61 /// Check all targets and tests (will be passed as `--all-targets`). 61 /// Check all targets and tests (`--all-targets`).
62 checkOnSave_allTargets: bool = "true", 62 checkOnSave_allTargets: bool = "true",
63 /// Cargo command to use for `cargo check`. 63 /// Cargo command to use for `cargo check`.
64 checkOnSave_command: String = "\"check\"", 64 checkOnSave_command: String = "\"check\"",
@@ -156,7 +156,7 @@ config_data! {
156 /// `rust-project.json`, or JSON objects in `rust-project.json` format. 156 /// `rust-project.json`, or JSON objects in `rust-project.json` format.
157 linkedProjects: Vec<ManifestOrProjectJson> = "[]", 157 linkedProjects: Vec<ManifestOrProjectJson> = "[]",
158 158
159 /// Number of syntax trees rust-analyzer keeps in memory. Defaults to 128. 159 /// Number of syntax trees rust-analyzer keeps in memory. Defaults to 128.
160 lruCapacity: Option<usize> = "null", 160 lruCapacity: Option<usize> = "null",
161 161
162 /// Whether to show `can't find Cargo.toml` error message. 162 /// Whether to show `can't find Cargo.toml` error message.
@@ -844,15 +844,32 @@ mod tests {
844 fn schema_in_sync_with_package_json() { 844 fn schema_in_sync_with_package_json() {
845 let s = Config::json_schema(); 845 let s = Config::json_schema();
846 let schema = format!("{:#}", s); 846 let schema = format!("{:#}", s);
847 let schema = schema.trim_start_matches('{').trim_end_matches('}'); 847 let mut schema = schema
848 848 .trim_start_matches('{')
849 let package_json = project_dir().join("editors/code/package.json"); 849 .trim_end_matches('}')
850 let package_json = fs::read_to_string(&package_json).unwrap(); 850 .replace(" ", " ")
851 851 .replace("\n", "\n ")
852 let p = remove_ws(&package_json); 852 .trim_start_matches('\n')
853 .trim_end()
854 .to_string();
855 schema.push_str(",\n");
856
857 let package_json_path = project_dir().join("editors/code/package.json");
858 let mut package_json = fs::read_to_string(&package_json_path).unwrap();
859
860 let start_marker = " \"$generated-start\": false,\n";
861 let end_marker = " \"$generated-end\": false\n";
862
863 let start = package_json.find(start_marker).unwrap() + start_marker.len();
864 let end = package_json.find(end_marker).unwrap();
865 let p = remove_ws(&package_json[start..end]);
853 let s = remove_ws(&schema); 866 let s = remove_ws(&schema);
854 867
855 assert!(p.contains(&s), "update config in package.json. New config:\n{:#}", schema); 868 if !p.contains(&s) {
869 package_json.replace_range(start..end, &schema);
870 fs::write(&package_json_path, &mut package_json).unwrap();
871 panic!("new config, updating package.json")
872 }
856 } 873 }
857 874
858 #[test] 875 #[test]