diff --git a/src/bin/main.rs b/src/bin/main.rs index caabb2ca..070c1ff2 100644 --- a/src/bin/main.rs +++ b/src/bin/main.rs @@ -26,7 +26,6 @@ pub fn main() -> anyhow::Result<()> { // Run the server and wait for the two threads to end (typically by trigger LSP Exit event). let hover_provider = Some(HoverProviderCapability::Simple(true)); - // TODO: Add % trigger character only if we're configured for GAS let completion_provider = Some(CompletionOptions { completion_item: Some(CompletionOptionsCompletionItem { label_details_support: Some(true), @@ -172,38 +171,6 @@ fn main_loop( Message::Request(req) => { if connection.handle_shutdown(&req)? { return Ok(()); - } else if let Ok((id, params)) = cast_req::(req.clone()) { - // CompletionRequest --------------------------------------------------------------- - let res = Response { - id: id.clone(), - result: Some(json!("")), - error: None, - }; - - // get suggestions ------------------------------------------------------ - // format response - let comp_res = get_comp_resp( - &curr_doc, - &mut parser, - ¶ms, - instruction_completes, - register_completes, - ); - match comp_res { - Some(_) => { - let result = serde_json::to_value(&comp_res).unwrap(); - let result = Response { - id: id.clone(), - result: Some(result), - error: None, - }; - connection.sender.send(Message::Response(result))?; - } - None => { - // don't know what to suggest - connection.sender.send(Message::Response(res.clone()))?; - } - } } else if let Ok((id, params)) = cast_req::(req.clone()) { // HoverRequest --------------------------------------------------------------- let res = Response { @@ -247,6 +214,38 @@ fn main_loop( connection.sender.send(Message::Response(res))?; } } + } else if let Ok((id, params)) = cast_req::(req.clone()) { + // CompletionRequest --------------------------------------------------------------- + let res = Response { + id: id.clone(), + result: Some(json!("")), + error: None, + }; + + // get suggestions ------------------------------------------------------ + // format response + let comp_res = get_comp_resp( + &curr_doc, + &mut parser, + ¶ms, + instruction_completes, + register_completes, + ); + match comp_res { + Some(_) => { + let result = serde_json::to_value(&comp_res).unwrap(); + let result = Response { + id: id.clone(), + result: Some(result), + error: None, + }; + connection.sender.send(Message::Response(result))?; + } + None => { + // don't know what to suggest + connection.sender.send(Message::Response(res.clone()))?; + } + } } else { error!("Invalid request fromat -> {:#?}", req); }