diff --git a/crates/ra_ide/src/completion/presentation.rs b/crates/ra_ide/src/completion/presentation.rs index d6196a5ced..aada4d025d 100644 --- a/crates/ra_ide/src/completion/presentation.rs +++ b/crates/ra_ide/src/completion/presentation.rs @@ -225,7 +225,7 @@ impl Completions { let snippet = if ctx .db .feature_flags - .get("completion.insertion.add-argument-sippets") + .get("completion.insertion.add-argument-snippets") { let to_skip = if has_self_param { 1 } else { 0 }; let function_params_snippet = join( diff --git a/crates/ra_ide_db/src/feature_flags.rs b/crates/ra_ide_db/src/feature_flags.rs index d9c9d6cd2b..9684150727 100644 --- a/crates/ra_ide_db/src/feature_flags.rs +++ b/crates/ra_ide_db/src/feature_flags.rs @@ -54,8 +54,9 @@ impl Default for FeatureFlags { FeatureFlags::new(&[ ("lsp.diagnostics", true), ("completion.insertion.add-call-parenthesis", true), - ("completion.insertion.add-argument-sippets", true), + ("completion.insertion.add-argument-snippets", true), ("completion.enable-postfix", true), + ("call-info.full", true), ("notifications.workspace-loaded", true), ("notifications.cargo-toml-not-found", true), ]) diff --git a/crates/rust-analyzer/src/conv.rs b/crates/rust-analyzer/src/conv.rs index fe3b588e4a..a2d68c344e 100644 --- a/crates/rust-analyzer/src/conv.rs +++ b/crates/rust-analyzer/src/conv.rs @@ -3,10 +3,10 @@ use lsp_types::{ self, CreateFile, DiagnosticSeverity, DocumentChangeOperation, DocumentChanges, Documentation, - Location, LocationLink, MarkupContent, MarkupKind, Position, Range, RenameFile, ResourceOp, - SemanticTokenModifier, SemanticTokenType, SymbolKind, TextDocumentEdit, TextDocumentIdentifier, - TextDocumentItem, TextDocumentPositionParams, Url, VersionedTextDocumentIdentifier, - WorkspaceEdit, + Location, LocationLink, MarkupContent, MarkupKind, ParameterInformation, ParameterLabel, + Position, Range, RenameFile, ResourceOp, SemanticTokenModifier, SemanticTokenType, + SignatureInformation, SymbolKind, TextDocumentEdit, TextDocumentIdentifier, TextDocumentItem, + TextDocumentPositionParams, Url, VersionedTextDocumentIdentifier, WorkspaceEdit, }; use ra_ide::{ translate_offset_with_edit, CompletionItem, CompletionItemKind, FileId, FilePosition, @@ -220,17 +220,20 @@ impl Conv for ra_ide::Documentation { } } -impl Conv for ra_ide::FunctionSignature { +impl ConvWith for ra_ide::FunctionSignature { type Output = lsp_types::SignatureInformation; - fn conv(self) -> Self::Output { - use lsp_types::{ParameterInformation, ParameterLabel, SignatureInformation}; + fn conv_with(self, concise: bool) -> Self::Output { + let (label, documentation, params) = if concise { + let mut params = self.parameters; + if self.has_self_param { + params.remove(0); + } + (params.join(", "), None, params) + } else { + (self.to_string(), self.doc.map(|it| it.conv()), self.parameters) + }; - let label = self.to_string(); - - let documentation = self.doc.map(|it| it.conv()); - - let parameters: Vec = self - .parameters + let parameters: Vec = params .into_iter() .map(|param| ParameterInformation { label: ParameterLabel::Simple(param), diff --git a/crates/rust-analyzer/src/main_loop/handlers.rs b/crates/rust-analyzer/src/main_loop/handlers.rs index b5db1fd387..b498c90c98 100644 --- a/crates/rust-analyzer/src/main_loop/handlers.rs +++ b/crates/rust-analyzer/src/main_loop/handlers.rs @@ -459,8 +459,12 @@ pub fn handle_signature_help( let _p = profile("handle_signature_help"); let position = params.try_conv_with(&world)?; if let Some(call_info) = world.analysis().call_info(position)? { - let active_parameter = call_info.active_parameter.map(|it| it as i64); - let sig_info = call_info.signature.conv(); + let concise = !world.analysis().feature_flags().get("call-info.full"); + let mut active_parameter = call_info.active_parameter.map(|it| it as i64); + if concise && call_info.signature.has_self_param { + active_parameter = active_parameter.map(|it| it.saturating_sub(1)); + } + let sig_info = call_info.signature.conv_with(concise); Ok(Some(req::SignatureHelp { signatures: vec![sig_info], diff --git a/editors/code/package.json b/editors/code/package.json index 2f442aae82..3a1e6cf231 100644 --- a/editors/code/package.json +++ b/editors/code/package.json @@ -197,7 +197,7 @@ "type": "boolean", "description": "Whether to add parenthesis when completing functions" }, - "completion.insertion.add-argument-sippets": { + "completion.insertion.add-argument-snippets": { "type": "boolean", "description": "Whether to add argument snippets when completing functions" }, @@ -205,6 +205,10 @@ "type": "boolean", "description": "Whether to show postfix snippets like `dbg`, `if`, `not`, etc." }, + "call-info.full": { + "type": "boolean", + "description": "Show function name and docs in parameter hints" + }, "notifications.workspace-loaded": { "type": "boolean", "description": "Whether to show `workspace loaded` message"