Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
WillLillis committed Nov 13, 2023
1 parent 9732b84 commit 844ba69
Showing 1 changed file with 32 additions and 33 deletions.
65 changes: 32 additions & 33 deletions src/bin/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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::<Completion>(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,
&params,
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::<HoverRequest>(req.clone()) {
// HoverRequest ---------------------------------------------------------------
let res = Response {
Expand Down Expand Up @@ -247,6 +214,38 @@ fn main_loop(
connection.sender.send(Message::Response(res))?;
}
}
} else if let Ok((id, params)) = cast_req::<Completion>(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,
&params,
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);
}
Expand Down

0 comments on commit 844ba69

Please sign in to comment.