Skip to content

Commit 23ffda1

Browse files
committed
full function signatures option
1 parent c405509 commit 23ffda1

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

crates/ide-completion/src/config.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ pub struct CompletionConfig {
1414
pub enable_imports_on_the_fly: bool,
1515
pub enable_self_on_the_fly: bool,
1616
pub enable_private_editable: bool,
17+
pub full_function_signatures: bool,
1718
pub callable: Option<CallableSnippets>,
1819
pub snippet_cap: Option<SnippetCap>,
1920
pub insert_use: InsertUseConfig,

crates/ide-completion/src/render/function.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ fn render(
100100

101101
item.set_documentation(ctx.docs(func))
102102
.set_deprecated(ctx.is_deprecated(func) || ctx.is_deprecated_assoc_item(func))
103-
.detail(detail(db, func))
103+
.detail(detail(db, func, ctx.completion.config.full_function_signatures))
104104
.lookup_by(name.unescaped().to_smol_str());
105105

106106
match ctx.completion.config.snippet_cap {
@@ -239,7 +239,11 @@ fn ref_of_param(ctx: &CompletionContext<'_>, arg: &str, ty: &hir::Type) -> &'sta
239239
""
240240
}
241241

242-
fn detail(db: &dyn HirDatabase, func: hir::Function) -> String {
242+
fn detail(db: &dyn HirDatabase, func: hir::Function, full_function_signature: bool) -> String {
243+
if full_function_signature {
244+
return format!("{}", func.display(db)).replace("\n", " ");
245+
}
246+
243247
let mut ret_ty = func.ret_type(db);
244248
let mut detail = String::new();
245249

crates/rust-analyzer/src/config.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,8 @@ config_data! {
215215
completion_postfix_enable: bool = "true",
216216
/// Enables completions of private items and fields that are defined in the current workspace even if they are not visible at the current position.
217217
completion_privateEditable_enable: bool = "false",
218+
/// Whether to show full function/method signatures in completion docs.
219+
completion_fullFunctionSignatures_enable: bool = "false",
218220
/// Custom completion snippets.
219221
// NOTE: Keep this list in sync with the feature docs of user snippets.
220222
completion_snippets_custom: FxHashMap<String, SnippetDef> = r#"{
@@ -1444,6 +1446,7 @@ impl Config {
14441446
&& completion_item_edit_resolve(&self.caps),
14451447
enable_self_on_the_fly: self.data.completion_autoself_enable,
14461448
enable_private_editable: self.data.completion_privateEditable_enable,
1449+
full_function_signatures: self.data.completion_fullFunctionSignatures_enable,
14471450
callable: match self.data.completion_callable_snippets {
14481451
CallableCompletionDef::FillArguments => Some(CallableSnippets::FillArguments),
14491452
CallableCompletionDef::AddParentheses => Some(CallableSnippets::AddParentheses),

0 commit comments

Comments
 (0)