aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-12-09 13:07:33 +0000
committerGitHub <[email protected]>2020-12-09 13:07:33 +0000
commit7bda4c722bc5bb81b0f5b0f4c9390e3c7b602d0f (patch)
tree59448726c277bc949487c0bbff6eb738861808b4
parent8fbaa8e49560b69f9017ebbced4a6571c2fbc64f (diff)
parent0890512e1c898c9c4c271df12d43353f3b64daf3 (diff)
Merge #6776
6776: Include config into the manual r=matklad a=matklad bors r+ 🤖 Co-authored-by: Aleksey Kladov <[email protected]>
-rw-r--r--crates/rust-analyzer/src/config.rs75
-rw-r--r--docs/user/generated_config.adoc106
-rw-r--r--docs/user/manual.adoc9
-rw-r--r--xtask/src/release.rs3
4 files changed, 174 insertions, 19 deletions
diff --git a/crates/rust-analyzer/src/config.rs b/crates/rust-analyzer/src/config.rs
index 345a56978..bd41a971b 100644
--- a/crates/rust-analyzer/src/config.rs
+++ b/crates/rust-analyzer/src/config.rs
@@ -637,6 +637,17 @@ macro_rules! _config_data {
637 },)* 637 },)*
638 ]) 638 ])
639 } 639 }
640
641 #[cfg(test)]
642 fn manual() -> String {
643 manual(&[
644 $({
645 let field = stringify!($field);
646 let ty = stringify!($ty);
647 (field, ty, &[$($doc),*], $default)
648 },)*
649 ])
650 }
640 } 651 }
641 }; 652 };
642} 653}
@@ -753,26 +764,54 @@ fn field_props(field: &str, ty: &str, doc: &[&str], default: &str) -> serde_json
753 map.into() 764 map.into()
754} 765}
755 766
756#[test] 767#[cfg(test)]
757fn schema_in_sync_with_package_json() { 768fn manual(fields: &[(&'static str, &'static str, &[&str], &str)]) -> String {
758 fn remove_ws(text: &str) -> String { 769 fields
759 text.replace(char::is_whitespace, "") 770 .iter()
760 } 771 .map(|(field, _ty, doc, default)| {
772 let name = field.replace("_", ".");
773 let name = format!("rust-analyzer.{} (default: `{}`)", name, default);
774 format!("{}::\n{}\n", name, doc.join(" "))
775 })
776 .collect::<String>()
777}
778
779#[cfg(test)]
780mod tests {
781 use std::fs;
782
783 use test_utils::project_dir;
784
785 use super::*;
761 786
762 let s = Config::json_schema(); 787 #[test]
763 let schema = format!("{:#}", s); 788 fn schema_in_sync_with_package_json() {
764 let schema = schema.trim_start_matches('{').trim_end_matches('}'); 789 let s = Config::json_schema();
790 let schema = format!("{:#}", s);
791 let schema = schema.trim_start_matches('{').trim_end_matches('}');
765 792
766 let package_json = std::env::current_dir() 793 let package_json = project_dir().join("editors/code/package.json");
767 .unwrap() 794 let package_json = fs::read_to_string(&package_json).unwrap();
768 .ancestors() 795
769 .nth(2) 796 let p = remove_ws(&package_json);
770 .unwrap() 797 let s = remove_ws(&schema);
771 .join("editors/code/package.json"); 798
772 let package_json = std::fs::read_to_string(&package_json).unwrap(); 799 assert!(p.contains(&s), "update config in package.json. New config:\n{:#}", schema);
800 }
773 801
774 let p = remove_ws(&package_json); 802 #[test]
775 let s = remove_ws(&schema); 803 fn schema_in_sync_with_docs() {
804 let docs_path = project_dir().join("docs/user/generated_config.adoc");
805 let current = fs::read_to_string(&docs_path).unwrap();
806 let expected = ConfigData::manual();
776 807
777 assert!(p.contains(&s), "update config in package.json. New config:\n{:#}", schema); 808 if remove_ws(&current) != remove_ws(&expected) {
809 fs::write(&docs_path, expected).unwrap();
810 panic!("updated config manual");
811 }
812 }
813
814 fn remove_ws(text: &str) -> String {
815 text.replace(char::is_whitespace, "")
816 }
778} 817}
diff --git a/docs/user/generated_config.adoc b/docs/user/generated_config.adoc
new file mode 100644
index 000000000..cb2ae6fc1
--- /dev/null
+++ b/docs/user/generated_config.adoc
@@ -0,0 +1,106 @@
1rust-analyzer.assist.importMergeBehaviour (default: `"full"`)::
2 The strategy to use when inserting new imports or merging imports.
3rust-analyzer.assist.importPrefix (default: `"plain"`)::
4 The path structure for newly inserted paths to use.
5rust-analyzer.callInfo.full (default: `true`)::
6 Show function name and docs in parameter hints.
7rust-analyzer.cargo.autoreload (default: `true`)::
8 Automatically refresh project info via `cargo metadata` on Cargo.toml changes.
9rust-analyzer.cargo.allFeatures (default: `false`)::
10 Activate all available features.
11rust-analyzer.cargo.features (default: `[]`)::
12 List of features to activate.
13rust-analyzer.cargo.loadOutDirsFromCheck (default: `false`)::
14 Run `cargo check` on startup to get the correct value for package OUT_DIRs.
15rust-analyzer.cargo.noDefaultFeatures (default: `false`)::
16 Do not activate the `default` feature.
17rust-analyzer.cargo.target (default: `null`)::
18 Compilation target (target triple).
19rust-analyzer.cargo.noSysroot (default: `false`)::
20 Internal config for debugging, disables loading of sysroot crates.
21rust-analyzer.checkOnSave.enable (default: `true`)::
22 Run specified `cargo check` command for diagnostics on save.
23rust-analyzer.checkOnSave.allFeatures (default: `null`)::
24 Check with all features (will be passed as `--all-features`). Defaults to `rust-analyzer.cargo.allFeatures`.
25rust-analyzer.checkOnSave.allTargets (default: `true`)::
26 Check all targets and tests (will be passed as `--all-targets`).
27rust-analyzer.checkOnSave.command (default: `"check"`)::
28 Cargo command to use for `cargo check`.
29rust-analyzer.checkOnSave.noDefaultFeatures (default: `null`)::
30 Do not activate the `default` feature.
31rust-analyzer.checkOnSave.target (default: `null`)::
32 Check for a specific target. Defaults to `rust-analyzer.cargo.target`.
33rust-analyzer.checkOnSave.extraArgs (default: `[]`)::
34 Extra arguments for `cargo check`.
35rust-analyzer.checkOnSave.features (default: `null`)::
36 List of features to activate. Defaults to `rust-analyzer.cargo.features`.
37rust-analyzer.checkOnSave.overrideCommand (default: `null`)::
38 Advanced option, fully override the command rust-analyzer uses for checking. The command should include `--message-format=json` or similar option.
39rust-analyzer.completion.addCallArgumentSnippets (default: `true`)::
40 Whether to add argument snippets when completing functions.
41rust-analyzer.completion.addCallParenthesis (default: `true`)::
42 Whether to add parenthesis when completing functions.
43rust-analyzer.completion.postfix.enable (default: `true`)::
44 Whether to show postfix snippets like `dbg`, `if`, `not`, etc.
45rust-analyzer.completion.autoimport.enable (default: `true`)::
46 Toggles the additional completions that automatically add imports when completed. Note that your client have to specify the `additionalTextEdits` LSP client capability to truly have this feature enabled.
47rust-analyzer.diagnostics.enable (default: `true`)::
48 Whether to show native rust-analyzer diagnostics.
49rust-analyzer.diagnostics.enableExperimental (default: `true`)::
50 Whether to show experimental rust-analyzer diagnostics that might have more false positives than usual.
51rust-analyzer.diagnostics.disabled (default: `[]`)::
52 List of rust-analyzer diagnostics to disable.
53rust-analyzer.diagnostics.warningsAsHint (default: `[]`)::
54 List of warnings that should be displayed with info severity.\nThe warnings will be indicated by a blue squiggly underline in code and a blue icon in the problems panel.
55rust-analyzer.diagnostics.warningsAsInfo (default: `[]`)::
56 List of warnings that should be displayed with hint severity.\nThe warnings will be indicated by faded text or three dots in code and will not show up in the problems panel.
57rust-analyzer.files.watcher (default: `"client"`)::
58 Controls file watching implementation.
59rust-analyzer.hoverActions.debug (default: `true`)::
60 Whether to show `Debug` action. Only applies when `#rust-analyzer.hoverActions.enable#` is set.
61rust-analyzer.hoverActions.enable (default: `true`)::
62 Whether to show HoverActions in Rust files.
63rust-analyzer.hoverActions.gotoTypeDef (default: `true`)::
64 Whether to show `Go to Type Definition` action. Only applies when `#rust-analyzer.hoverActions.enable#` is set.
65rust-analyzer.hoverActions.implementations (default: `true`)::
66 Whether to show `Implementations` action. Only applies when `#rust-analyzer.hoverActions.enable#` is set.
67rust-analyzer.hoverActions.run (default: `true`)::
68 Whether to show `Run` action. Only applies when `#rust-analyzer.hoverActions.enable#` is set.
69rust-analyzer.hoverActions.linksInHover (default: `true`)::
70 Use markdown syntax for links in hover.
71rust-analyzer.inlayHints.chainingHints (default: `true`)::
72 Whether to show inlay type hints for method chains.
73rust-analyzer.inlayHints.maxLength (default: `null`)::
74 Maximum length for inlay hints.
75rust-analyzer.inlayHints.parameterHints (default: `true`)::
76 Whether to show function parameter name inlay hints at the call site.
77rust-analyzer.inlayHints.typeHints (default: `true`)::
78 Whether to show inlay type hints for variables.
79rust-analyzer.lens.debug (default: `true`)::
80 Whether to show `Debug` lens. Only applies when `#rust-analyzer.lens.enable#` is set.
81rust-analyzer.lens.enable (default: `true`)::
82 Whether to show CodeLens in Rust files.
83rust-analyzer.lens.implementations (default: `true`)::
84 Whether to show `Implementations` lens. Only applies when `#rust-analyzer.lens.enable#` is set.
85rust-analyzer.lens.run (default: `true`)::
86 Whether to show `Run` lens. Only applies when `#rust-analyzer.lens.enable#` is set.
87rust-analyzer.lens.methodReferences (default: `false`)::
88 Whether to show `Method References` lens. Only applies when `#rust-analyzer.lens.enable#` is set.
89rust-analyzer.linkedProjects (default: `[]`)::
90 Disable project auto-discovery in favor of explicitly specified set of projects. \nElements must be paths pointing to Cargo.toml, rust-project.json, or JSON objects in rust-project.json format.
91rust-analyzer.lruCapacity (default: `null`)::
92 Number of syntax trees rust-analyzer keeps in memory.
93rust-analyzer.notifications.cargoTomlNotFound (default: `true`)::
94 Whether to show `can't find Cargo.toml` error message.
95rust-analyzer.procMacro.enable (default: `false`)::
96 Enable Proc macro support, cargo.loadOutDirsFromCheck must be enabled.
97rust-analyzer.runnables.overrideCargo (default: `null`)::
98 Command to be executed instead of 'cargo' for runnables.
99rust-analyzer.runnables.cargoExtraArgs (default: `[]`)::
100 Additional arguments to be passed to cargo for runnables such as tests or binaries.\nFor example, it may be '--release'.
101rust-analyzer.rustcSource (default: `null`)::
102 Path to the rust compiler sources, for usage in rustc_private projects.
103rust-analyzer.rustfmt.extraArgs (default: `[]`)::
104 Additional arguments to rustfmt.
105rust-analyzer.rustfmt.overrideCommand (default: `null`)::
106 Advanced option, fully override the command rust-analyzer uses for formatting.
diff --git a/docs/user/manual.adoc b/docs/user/manual.adoc
index 575e5866f..f506d243f 100644
--- a/docs/user/manual.adoc
+++ b/docs/user/manual.adoc
@@ -263,6 +263,15 @@ If you get an error saying `No such file or directory: 'rust-analyzer'`, see the
263 263
264GNOME Builder 3.37.1 and newer has native `rust-analyzer` support. If the LSP binary is not available, GNOME Builder can install it when opening a Rust file. 264GNOME Builder 3.37.1 and newer has native `rust-analyzer` support. If the LSP binary is not available, GNOME Builder can install it when opening a Rust file.
265 265
266== Configration
267
268rust-analyzer is configured via LSP messages, which means that it's up to the editor to decide on the exact format and location of configuration files.
269Please consult your editor's documentation to learn how to configure LSP servers.
270
271This is the list of config options rust-analyzer supports:
272
273include::./generated_config.adoc[]
274
266== Non-Cargo Based Projects 275== Non-Cargo Based Projects
267 276
268rust-analyzer does not require Cargo. 277rust-analyzer does not require Cargo.
diff --git a/xtask/src/release.rs b/xtask/src/release.rs
index 3cf0d849f..2d716253e 100644
--- a/xtask/src/release.rs
+++ b/xtask/src/release.rs
@@ -54,9 +54,10 @@ https://github.com/sponsors/rust-analyzer[GitHub Sponsors].
54 54
55 for &adoc in [ 55 for &adoc in [
56 "manual.adoc", 56 "manual.adoc",
57 "generated_features.adoc",
58 "generated_assists.adoc", 57 "generated_assists.adoc",
58 "generated_config.adoc",
59 "generated_diagnostic.adoc", 59 "generated_diagnostic.adoc",
60 "generated_features.adoc",
60 ] 61 ]
61 .iter() 62 .iter()
62 { 63 {