From 01b3ce30067fb52e0c555c1db09e81ac6767a90c Mon Sep 17 00:00:00 2001 From: Wang Ruochen Date: Mon, 10 Jan 2022 20:47:54 -0800 Subject: [PATCH] Fix documentation of snippet --- crates/rust-analyzer/src/config.rs | 18 +++++++++++++++++- docs/user/generated_config.adoc | 13 +++++++++---- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/crates/rust-analyzer/src/config.rs b/crates/rust-analyzer/src/config.rs index 88d86ef503..1df19ffe78 100644 --- a/crates/rust-analyzer/src/config.rs +++ b/crates/rust-analyzer/src/config.rs @@ -1364,7 +1364,23 @@ fn manual(fields: &[(&'static str, &'static str, &[&str], &str)]) -> String { .map(|(field, _ty, doc, default)| { let name = format!("rust-analyzer.{}", field.replace("_", ".")); let doc = doc_comment_to_string(*doc); - format!("[[{}]]{} (default: `{}`)::\n+\n--\n{}--\n", name, name, default, doc) + if default.contains('\n') { + format!( + r#"[[{}]]{}:: ++ +-- +Default: +---- +{} +---- +{} +-- +"#, + name, name, default, doc + ) + } else { + format!("[[{}]]{} (default: `{}`)::\n+\n--\n{}--\n", name, name, default, doc) + } }) .collect::() } diff --git a/docs/user/generated_config.adoc b/docs/user/generated_config.adoc index 88dcacfe83..f7a533c7c2 100644 --- a/docs/user/generated_config.adoc +++ b/docs/user/generated_config.adoc @@ -146,7 +146,12 @@ Only applies when `#rust-analyzer.completion.addCallParenthesis#` is set. -- Whether to add parenthesis when completing functions. -- -[[rust-analyzer.completion.snippets]]rust-analyzer.completion.snippets (default: `{ +[[rust-analyzer.completion.snippets]]rust-analyzer.completion.snippets:: ++ +-- +Default: +---- +{ "Arc::new": { "postfix": "arc", "body": "Arc::new(${receiver})", @@ -186,10 +191,10 @@ Whether to add parenthesis when completing functions. "description": "Wrap the expression in an `Option::Some`", "scope": "expr" } - }`):: -+ --- + } +---- Custom completion snippets. + -- [[rust-analyzer.completion.postfix.enable]]rust-analyzer.completion.postfix.enable (default: `true`):: +