|
|
@ -857,21 +857,15 @@ pub fn completion(cx: &mut Context) {
|
|
|
|
let language_server = cx.language_servers.get("rust", &cx.executor).unwrap();
|
|
|
|
let language_server = cx.language_servers.get("rust", &cx.executor).unwrap();
|
|
|
|
use log::info;
|
|
|
|
use log::info;
|
|
|
|
|
|
|
|
|
|
|
|
use smol_timeout::TimeoutExt;
|
|
|
|
|
|
|
|
use std::time::Duration;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: blocking here is not ideal
|
|
|
|
// TODO: blocking here is not ideal
|
|
|
|
let pos = helix_lsp::util::pos_to_lsp_pos(
|
|
|
|
let pos = helix_lsp::util::pos_to_lsp_pos(
|
|
|
|
&cx.view.doc.text().slice(..),
|
|
|
|
&cx.view.doc.text().slice(..),
|
|
|
|
cx.view.doc.selection().cursor(),
|
|
|
|
cx.view.doc.selection().cursor(),
|
|
|
|
);
|
|
|
|
);
|
|
|
|
let res = smol::block_on(
|
|
|
|
|
|
|
|
language_server
|
|
|
|
// TODO: handle fails
|
|
|
|
.completion(cx.view.doc.identifier(), pos)
|
|
|
|
let res = smol::block_on(language_server.completion(cx.view.doc.identifier(), pos))
|
|
|
|
.timeout(Duration::from_secs(2)),
|
|
|
|
.unwrap_or_default();
|
|
|
|
)
|
|
|
|
|
|
|
|
.expect("completion failed!")
|
|
|
|
|
|
|
|
.unwrap_or_default(); // if timeout, just return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: if no completion, show some message or something
|
|
|
|
// TODO: if no completion, show some message or something
|
|
|
|
if !res.is_empty() {
|
|
|
|
if !res.is_empty() {
|
|
|
|