From 9baf1ecc90117710e785467f59a99ee119f50c73 Mon Sep 17 00:00:00 2001 From: Robin Date: Sat, 12 Jun 2021 14:45:21 +0200 Subject: add symbol picker (#230) * add symbol picker use the lsp document_symbol request * fix errors from merging in master * add docs for symbol picker--- helix-lsp/src/client.rs | 13 +++++++++++++ helix-lsp/src/lib.rs | 11 +++++++++++ 2 files changed, 24 insertions(+) (limited to 'helix-lsp/src') diff --git a/helix-lsp/src/client.rs b/helix-lsp/src/client.rs index 070f90d1..9ca708a7 100644 --- a/helix-lsp/src/client.rs +++ b/helix-lsp/src/client.rs @@ -660,4 +660,17 @@ impl Client { self.call::(params) } + + pub fn document_symbols( + &self, + text_document: lsp::TextDocumentIdentifier, + ) -> impl Future> { + let params = lsp::DocumentSymbolParams { + text_document, + work_done_progress_params: lsp::WorkDoneProgressParams::default(), + partial_result_params: lsp::PartialResultParams::default(), + }; + + self.call::(params) + } } diff --git a/helix-lsp/src/lib.rs b/helix-lsp/src/lib.rs index e16ad765..cff62492 100644 --- a/helix-lsp/src/lib.rs +++ b/helix-lsp/src/lib.rs @@ -138,6 +138,17 @@ pub mod util { lsp::Range::new(start, end) } + pub fn lsp_range_to_range( + doc: &Rope, + range: lsp::Range, + offset_encoding: OffsetEncoding, + ) -> Option { + let start = lsp_pos_to_pos(doc, range.start, offset_encoding)?; + let end = lsp_pos_to_pos(doc, range.end, offset_encoding)?; + + Some(Range::new(start, end)) + } + pub fn generate_transaction_from_edits( doc: &Rope, edits: Vec, -- cgit v1.2.3-70-g09d2