From 791bf7e50a19bcf7612788deb7514847089cb976 Mon Sep 17 00:00:00 2001 From: Gokul Soumya Date: Tue, 19 Jul 2022 07:58:24 +0530 Subject: Add lsp signature help (#1755) * Add lsp signature help * Do not move signature help popup on multiple triggers * Highlight current parameter in signature help * Auto close signature help * Position signature help above to not block completion * Update signature help on backspace/insert mode delete * Add lsp.auto-signature-help config option * Add serde default annotation for LspConfig * Show LSP inactive message only if signature help is invoked manually * Do not assume valid signature help response from LSP Malformed LSP responses are common, and these should not crash the editor. * Check signature help capability before sending request * Reuse Open enum for PositionBias in popup * Close signature popup and exit insert mode on escape * Add config to control signature help docs display * Use new Margin api in signature help * Invoke signature help on changing to insert mode--- helix-lsp/src/client.rs | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'helix-lsp/src') diff --git a/helix-lsp/src/client.rs b/helix-lsp/src/client.rs index 9187a61e..f6cec6aa 100644 --- a/helix-lsp/src/client.rs +++ b/helix-lsp/src/client.rs @@ -322,6 +322,16 @@ impl Client { content_format: Some(vec![lsp::MarkupKind::Markdown]), ..Default::default() }), + signature_help: Some(lsp::SignatureHelpClientCapabilities { + signature_information: Some(lsp::SignatureInformationSettings { + documentation_format: Some(vec![lsp::MarkupKind::Markdown]), + parameter_information: Some(lsp::ParameterInformationSettings { + label_offset_support: Some(true), + }), + active_parameter_support: Some(true), + }), + ..Default::default() + }), rename: Some(lsp::RenameClientCapabilities { dynamic_registration: Some(false), prepare_support: Some(false), @@ -646,7 +656,12 @@ impl Client { text_document: lsp::TextDocumentIdentifier, position: lsp::Position, work_done_token: Option, - ) -> impl Future> { + ) -> Option>> { + let capabilities = self.capabilities.get().unwrap(); + + // Return early if signature help is not supported + capabilities.signature_help_provider.as_ref()?; + let params = lsp::SignatureHelpParams { text_document_position_params: lsp::TextDocumentPositionParams { text_document, @@ -657,7 +672,7 @@ impl Client { // lsp::SignatureHelpContext }; - self.call::(params) + Some(self.call::(params)) } pub fn text_document_hover( -- cgit v1.2.3-70-g09d2