aboutsummaryrefslogtreecommitdiff
path: root/helix-term
diff options
context:
space:
mode:
authorBlaž Hrastnik2020-12-23 08:03:20 +0000
committerBlaž Hrastnik2020-12-23 09:16:17 +0000
commitcd16df19c1f951e1ef0c560ae5e084b18bd2c713 (patch)
tree82b1431a96c914033fff8b79fcdcda9f535a16f9 /helix-term
parent56f2193811fca2fa20284442c2042fa271464445 (diff)
lsp: generate_transaction_from_text_edits
Diffstat (limited to 'helix-term')
-rw-r--r--helix-term/Cargo.toml1
-rw-r--r--helix-term/src/commands.rs17
2 files changed, 17 insertions, 1 deletions
diff --git a/helix-term/Cargo.toml b/helix-term/Cargo.toml
index 645ed155..67e8f443 100644
--- a/helix-term/Cargo.toml
+++ b/helix-term/Cargo.toml
@@ -20,6 +20,7 @@ anyhow = "1"
once_cell = "1.4"
smol = "1"
+smol-timeout = "0.6"
num_cpus = "1"
# tui = { version = "0.12", default-features = false, features = ["crossterm"] }
tui = { git = "https://github.com/fdehau/tui-rs", default-features = false, features = ["crossterm"] }
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs
index eb23041c..862cf312 100644
--- a/helix-term/src/commands.rs
+++ b/helix-term/src/commands.rs
@@ -837,17 +837,32 @@ pub fn completion(cx: &mut Context) {
let language_server = cx.language_servers.get("rust", &cx.executor).unwrap();
use log::info;
+ use smol_timeout::TimeoutExt;
+ use std::time::Duration;
+
// TODO: blocking here is not ideal
- let res = smol::block_on(language_server.completion(&cx.view.doc)).expect("completion failed!");
+ let res = smol::block_on(
+ language_server
+ .completion(&cx.view.doc)
+ .timeout(Duration::from_secs(2)),
+ )
+ .expect("completion failed!")
+ .expect("completion failed!");
let picker = ui::Picker::new(
res,
|item| {
// format_fn
item.label.as_str().into()
+
+ // TODO: use item.filter_text for filtering
},
|editor: &mut Editor, item| {
+ // if item.text_edit is Some we use that, else
+ // let insert_text = &item.insert_text.unwrap_or(item.label);
+ // and we insert at position.
//
+ // merge this with additional_text_edits
},
);