Add `work_done_token` as parameter to lsp methods

pull/297/head
wojciechkepka 3 years ago committed by Blaž Hrastnik
parent 52fb90b81e
commit a6d39585d8

@ -465,6 +465,7 @@ impl Client {
&self, &self,
text_document: lsp::TextDocumentIdentifier, text_document: lsp::TextDocumentIdentifier,
position: lsp::Position, position: lsp::Position,
work_done_token: Option<lsp::ProgressToken>,
) -> impl Future<Output = Result<Value>> { ) -> impl Future<Output = Result<Value>> {
// ) -> Result<Vec<lsp::CompletionItem>> { // ) -> Result<Vec<lsp::CompletionItem>> {
let params = lsp::CompletionParams { let params = lsp::CompletionParams {
@ -473,9 +474,7 @@ impl Client {
position, position,
}, },
// TODO: support these tokens by async receiving and updating the choice list // TODO: support these tokens by async receiving and updating the choice list
work_done_progress_params: lsp::WorkDoneProgressParams { work_done_progress_params: lsp::WorkDoneProgressParams { work_done_token },
work_done_token: None,
},
partial_result_params: lsp::PartialResultParams { partial_result_params: lsp::PartialResultParams {
partial_result_token: None, partial_result_token: None,
}, },
@ -490,15 +489,14 @@ impl Client {
&self, &self,
text_document: lsp::TextDocumentIdentifier, text_document: lsp::TextDocumentIdentifier,
position: lsp::Position, position: lsp::Position,
work_done_token: Option<lsp::ProgressToken>,
) -> impl Future<Output = Result<Value>> { ) -> impl Future<Output = Result<Value>> {
let params = lsp::SignatureHelpParams { let params = lsp::SignatureHelpParams {
text_document_position_params: lsp::TextDocumentPositionParams { text_document_position_params: lsp::TextDocumentPositionParams {
text_document, text_document,
position, position,
}, },
work_done_progress_params: lsp::WorkDoneProgressParams { work_done_progress_params: lsp::WorkDoneProgressParams { work_done_token },
work_done_token: None,
},
context: None, context: None,
// lsp::SignatureHelpContext // lsp::SignatureHelpContext
}; };
@ -510,15 +508,14 @@ impl Client {
&self, &self,
text_document: lsp::TextDocumentIdentifier, text_document: lsp::TextDocumentIdentifier,
position: lsp::Position, position: lsp::Position,
work_done_token: Option<lsp::ProgressToken>,
) -> impl Future<Output = Result<Value>> { ) -> impl Future<Output = Result<Value>> {
let params = lsp::HoverParams { let params = lsp::HoverParams {
text_document_position_params: lsp::TextDocumentPositionParams { text_document_position_params: lsp::TextDocumentPositionParams {
text_document, text_document,
position, position,
}, },
work_done_progress_params: lsp::WorkDoneProgressParams { work_done_progress_params: lsp::WorkDoneProgressParams { work_done_token },
work_done_token: None,
},
// lsp::SignatureHelpContext // lsp::SignatureHelpContext
}; };
@ -531,6 +528,7 @@ impl Client {
&self, &self,
text_document: lsp::TextDocumentIdentifier, text_document: lsp::TextDocumentIdentifier,
options: lsp::FormattingOptions, options: lsp::FormattingOptions,
work_done_token: Option<lsp::ProgressToken>,
) -> anyhow::Result<Vec<lsp::TextEdit>> { ) -> anyhow::Result<Vec<lsp::TextEdit>> {
let capabilities = self.capabilities.as_ref().unwrap(); let capabilities = self.capabilities.as_ref().unwrap();
@ -545,9 +543,7 @@ impl Client {
let params = lsp::DocumentFormattingParams { let params = lsp::DocumentFormattingParams {
text_document, text_document,
options, options,
work_done_progress_params: lsp::WorkDoneProgressParams { work_done_progress_params: lsp::WorkDoneProgressParams { work_done_token },
work_done_token: None,
},
}; };
let response = self.request::<lsp::request::Formatting>(params).await?; let response = self.request::<lsp::request::Formatting>(params).await?;
@ -560,6 +556,7 @@ impl Client {
text_document: lsp::TextDocumentIdentifier, text_document: lsp::TextDocumentIdentifier,
range: lsp::Range, range: lsp::Range,
options: lsp::FormattingOptions, options: lsp::FormattingOptions,
work_done_token: Option<lsp::ProgressToken>,
) -> anyhow::Result<Vec<lsp::TextEdit>> { ) -> anyhow::Result<Vec<lsp::TextEdit>> {
let capabilities = self.capabilities.as_ref().unwrap(); let capabilities = self.capabilities.as_ref().unwrap();
@ -575,9 +572,7 @@ impl Client {
text_document, text_document,
range, range,
options, options,
work_done_progress_params: lsp::WorkDoneProgressParams { work_done_progress_params: lsp::WorkDoneProgressParams { work_done_token },
work_done_token: None,
},
}; };
let response = self let response = self
@ -596,15 +591,14 @@ impl Client {
&self, &self,
text_document: lsp::TextDocumentIdentifier, text_document: lsp::TextDocumentIdentifier,
position: lsp::Position, position: lsp::Position,
work_done_token: Option<lsp::ProgressToken>,
) -> impl Future<Output = Result<Value>> { ) -> impl Future<Output = Result<Value>> {
let params = lsp::GotoDefinitionParams { let params = lsp::GotoDefinitionParams {
text_document_position_params: lsp::TextDocumentPositionParams { text_document_position_params: lsp::TextDocumentPositionParams {
text_document, text_document,
position, position,
}, },
work_done_progress_params: lsp::WorkDoneProgressParams { work_done_progress_params: lsp::WorkDoneProgressParams { work_done_token },
work_done_token: None,
},
partial_result_params: lsp::PartialResultParams { partial_result_params: lsp::PartialResultParams {
partial_result_token: None, partial_result_token: None,
}, },
@ -617,30 +611,42 @@ impl Client {
&self, &self,
text_document: lsp::TextDocumentIdentifier, text_document: lsp::TextDocumentIdentifier,
position: lsp::Position, position: lsp::Position,
work_done_token: Option<lsp::ProgressToken>,
) -> impl Future<Output = Result<Value>> { ) -> impl Future<Output = Result<Value>> {
self.goto_request::<lsp::request::GotoDefinition>(text_document, position) self.goto_request::<lsp::request::GotoDefinition>(text_document, position, work_done_token)
} }
pub fn goto_type_definition( pub fn goto_type_definition(
&self, &self,
text_document: lsp::TextDocumentIdentifier, text_document: lsp::TextDocumentIdentifier,
position: lsp::Position, position: lsp::Position,
work_done_token: Option<lsp::ProgressToken>,
) -> impl Future<Output = Result<Value>> { ) -> impl Future<Output = Result<Value>> {
self.goto_request::<lsp::request::GotoTypeDefinition>(text_document, position) self.goto_request::<lsp::request::GotoTypeDefinition>(
text_document,
position,
work_done_token,
)
} }
pub fn goto_implementation( pub fn goto_implementation(
&self, &self,
text_document: lsp::TextDocumentIdentifier, text_document: lsp::TextDocumentIdentifier,
position: lsp::Position, position: lsp::Position,
work_done_token: Option<lsp::ProgressToken>,
) -> impl Future<Output = Result<Value>> { ) -> impl Future<Output = Result<Value>> {
self.goto_request::<lsp::request::GotoImplementation>(text_document, position) self.goto_request::<lsp::request::GotoImplementation>(
text_document,
position,
work_done_token,
)
} }
pub fn goto_reference( pub fn goto_reference(
&self, &self,
text_document: lsp::TextDocumentIdentifier, text_document: lsp::TextDocumentIdentifier,
position: lsp::Position, position: lsp::Position,
work_done_token: Option<lsp::ProgressToken>,
) -> impl Future<Output = Result<Value>> { ) -> impl Future<Output = Result<Value>> {
let params = lsp::ReferenceParams { let params = lsp::ReferenceParams {
text_document_position: lsp::TextDocumentPositionParams { text_document_position: lsp::TextDocumentPositionParams {
@ -650,9 +656,7 @@ impl Client {
context: lsp::ReferenceContext { context: lsp::ReferenceContext {
include_declaration: true, include_declaration: true,
}, },
work_done_progress_params: lsp::WorkDoneProgressParams { work_done_progress_params: lsp::WorkDoneProgressParams { work_done_token },
work_done_token: None,
},
partial_result_params: lsp::PartialResultParams { partial_result_params: lsp::PartialResultParams {
partial_result_token: None, partial_result_token: None,
}, },

@ -1852,7 +1852,7 @@ fn goto_definition(cx: &mut Context) {
let pos = pos_to_lsp_pos(doc.text(), doc.selection(view.id).cursor(), offset_encoding); let pos = pos_to_lsp_pos(doc.text(), doc.selection(view.id).cursor(), offset_encoding);
// TODO: handle fails // TODO: handle fails
let future = language_server.goto_definition(doc.identifier(), pos); let future = language_server.goto_definition(doc.identifier(), pos, None);
cx.callback( cx.callback(
future, future,
@ -1889,7 +1889,7 @@ fn goto_type_definition(cx: &mut Context) {
let pos = pos_to_lsp_pos(doc.text(), doc.selection(view.id).cursor(), offset_encoding); let pos = pos_to_lsp_pos(doc.text(), doc.selection(view.id).cursor(), offset_encoding);
// TODO: handle fails // TODO: handle fails
let future = language_server.goto_type_definition(doc.identifier(), pos); let future = language_server.goto_type_definition(doc.identifier(), pos, None);
cx.callback( cx.callback(
future, future,
@ -1926,7 +1926,7 @@ fn goto_implementation(cx: &mut Context) {
let pos = pos_to_lsp_pos(doc.text(), doc.selection(view.id).cursor(), offset_encoding); let pos = pos_to_lsp_pos(doc.text(), doc.selection(view.id).cursor(), offset_encoding);
// TODO: handle fails // TODO: handle fails
let future = language_server.goto_implementation(doc.identifier(), pos); let future = language_server.goto_implementation(doc.identifier(), pos, None);
cx.callback( cx.callback(
future, future,
@ -1963,7 +1963,7 @@ fn goto_reference(cx: &mut Context) {
let pos = pos_to_lsp_pos(doc.text(), doc.selection(view.id).cursor(), offset_encoding); let pos = pos_to_lsp_pos(doc.text(), doc.selection(view.id).cursor(), offset_encoding);
// TODO: handle fails // TODO: handle fails
let future = language_server.goto_reference(doc.identifier(), pos); let future = language_server.goto_reference(doc.identifier(), pos, None);
cx.callback( cx.callback(
future, future,
@ -2075,7 +2075,7 @@ fn signature_help(cx: &mut Context) {
); );
// TODO: handle fails // TODO: handle fails
let future = language_server.text_document_signature_help(doc.identifier(), pos); let future = language_server.text_document_signature_help(doc.identifier(), pos, None);
cx.callback( cx.callback(
future, future,
@ -2718,7 +2718,7 @@ fn completion(cx: &mut Context) {
let pos = pos_to_lsp_pos(doc.text(), doc.selection(view.id).cursor(), offset_encoding); let pos = pos_to_lsp_pos(doc.text(), doc.selection(view.id).cursor(), offset_encoding);
// TODO: handle fails // TODO: handle fails
let future = language_server.completion(doc.identifier(), pos); let future = language_server.completion(doc.identifier(), pos, None);
let trigger_offset = doc.selection(view.id).cursor(); let trigger_offset = doc.selection(view.id).cursor();
@ -2776,7 +2776,7 @@ fn hover(cx: &mut Context) {
); );
// TODO: handle fails // TODO: handle fails
let future = language_server.text_document_hover(doc.identifier(), pos); let future = language_server.text_document_hover(doc.identifier(), pos, None);
cx.callback( cx.callback(
future, future,

@ -263,10 +263,11 @@ impl Document {
pub fn format(&mut self, view_id: ViewId) { pub fn format(&mut self, view_id: ViewId) {
if let Some(language_server) = self.language_server() { if let Some(language_server) = self.language_server() {
// TODO: await, no blocking // TODO: await, no blocking
let transaction = helix_lsp::block_on( let transaction = helix_lsp::block_on(language_server.text_document_formatting(
language_server self.identifier(),
.text_document_formatting(self.identifier(), lsp::FormattingOptions::default()), lsp::FormattingOptions::default(),
) None,
))
.map(|edits| { .map(|edits| {
helix_lsp::util::generate_transaction_from_edits( helix_lsp::util::generate_transaction_from_edits(
self.text(), self.text(),

Loading…
Cancel
Save