aboutsummaryrefslogtreecommitdiff
path: root/helix-view
diff options
context:
space:
mode:
authorBlaž Hrastnik2021-05-06 04:56:34 +0000
committerBlaž Hrastnik2021-05-06 04:56:34 +0000
commit355ad3cb8289611b06cd42fa62ddfe0a5c716e83 (patch)
tree7c94da6e122a9ecf542103b46a3ca9e80654a52e /helix-view
parent0e5308bce1a6e7d7d00854ae50902546cea9578d (diff)
Tokio migration.
Diffstat (limited to 'helix-view')
-rw-r--r--helix-view/Cargo.toml2
-rw-r--r--helix-view/src/document.rs6
-rw-r--r--helix-view/src/editor.rs16
3 files changed, 13 insertions, 11 deletions
diff --git a/helix-view/Cargo.toml b/helix-view/Cargo.toml
index a49d440c..2ed58707 100644
--- a/helix-view/Cargo.toml
+++ b/helix-view/Cargo.toml
@@ -21,7 +21,7 @@ crossterm = { version = "0.19", features = ["event-stream"], optional = true }
once_cell = "1.4"
url = "2"
-smol = "1"
+tokio = { version = "1", features = ["full"] }
futures-util = "0.3"
slotmap = "1"
diff --git a/helix-view/src/document.rs b/helix-view/src/document.rs
index 9b6f3cca..8d6144cf 100644
--- a/helix-view/src/document.rs
+++ b/helix-view/src/document.rs
@@ -134,7 +134,7 @@ impl Document {
self.last_saved_revision = self.history.current_revision();
async move {
- use smol::{fs::File, prelude::*};
+ use tokio::{fs::File, io::AsyncWriteExt};
let mut file = File::create(path).await?;
// write all the rope chunks to file
@@ -232,7 +232,9 @@ impl Document {
transaction.changes(),
);
- smol::block_on(notify).expect("failed to emit textDocument/didChange");
+ if let Some(notify) = notify {
+ tokio::spawn(notify);
+ } //.expect("failed to emit textDocument/didChange");
}
}
success
diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs
index 0eab4fe7..014364e0 100644
--- a/helix-view/src/editor.rs
+++ b/helix-view/src/editor.rs
@@ -13,7 +13,6 @@ pub struct Editor {
pub count: Option<usize>,
pub theme: Theme,
pub language_servers: helix_lsp::Registry,
- pub executor: &'static smol::Executor<'static>,
}
#[derive(Copy, Clone)]
@@ -24,7 +23,7 @@ pub enum Action {
}
impl Editor {
- pub fn new(executor: &'static smol::Executor<'static>, mut area: tui::layout::Rect) -> Self {
+ pub fn new(mut area: tui::layout::Rect) -> Self {
use helix_core::config_dir;
let config = std::fs::read(config_dir().join("theme.toml"));
// load $HOME/.config/helix/theme.toml, fallback to default config
@@ -44,7 +43,6 @@ impl Editor {
count: None,
theme,
language_servers,
- executor,
}
}
@@ -122,7 +120,7 @@ impl Editor {
let language_server = doc
.language
.as_ref()
- .and_then(|language| self.language_servers.get(language, self.executor));
+ .and_then(|language| self.language_servers.get(language));
if let Some(language_server) = language_server {
doc.set_language_server(Some(language_server.clone()));
@@ -133,7 +131,8 @@ impl Editor {
.map(ToOwned::to_owned)
.unwrap_or_default();
- smol::block_on(language_server.text_document_did_open(
+ let rt = tokio::runtime::Handle::current();
+ rt.block_on(language_server.text_document_did_open(
doc.url().unwrap(),
doc.version(),
doc.text(),
@@ -154,17 +153,18 @@ impl Editor {
let view = self.tree.get(self.tree.focus);
// get around borrowck issues
let language_servers = &mut self.language_servers;
- let executor = self.executor;
let doc = &self.documents[view.doc];
let language_server = doc
.language
.as_ref()
- .and_then(|language| language_servers.get(language, executor));
+ .and_then(|language| language_servers.get(language));
if let Some(language_server) = language_server {
- smol::block_on(language_server.text_document_did_close(doc.identifier())).unwrap();
+ let rt = tokio::runtime::Handle::current();
+ rt.block_on(language_server.text_document_did_close(doc.identifier()))
+ .unwrap();
}
// remove selection