diff --git a/Cargo.lock b/Cargo.lock index 1b55de79526..9a099308613 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -357,14 +357,14 @@ dependencies = [ [[package]] name = "async-lsp" -version = "0.0.4" -source = "git+https://github.com/oxalica/async-lsp?rev=09dbcc11046f7a188a80137f8d36484d86c78c78#09dbcc11046f7a188a80137f8d36484d86c78c78" +version = "0.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72bd600f2652d2cccb0a33ab4f92d163ab3930844c8b0ad3713a5ae3285eeb4e" dependencies = [ - "either", "futures", "lsp-types 0.94.0", "pin-project-lite", - "rustix 0.37.23", + "rustix 0.38.4", "serde", "serde_json", "thiserror", @@ -372,7 +372,7 @@ dependencies = [ "tower-layer", "tower-service", "tracing", - "windows-sys 0.48.0", + "waitpid-any", ] [[package]] @@ -2024,6 +2024,7 @@ dependencies = [ "termcolor", "thiserror", "tokio", + "tokio-util", "toml", "tower", ] @@ -3382,6 +3383,7 @@ checksum = "806fe8c2c87eccc8b3267cbae29ed3ab2d0bd37fca70ab622e46aaa9375ddb7d" dependencies = [ "bytes", "futures-core", + "futures-io", "futures-sink", "pin-project-lite", "tokio", @@ -3596,6 +3598,16 @@ dependencies = [ "libc", ] +[[package]] +name = "waitpid-any" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "54f8c3c56044fc359f905b72879576a15d49c46d085ed6266a98826716f14033" +dependencies = [ + "rustix 0.38.4", + "windows-sys 0.48.0", +] + [[package]] name = "walkdir" version = "2.3.3" diff --git a/Cargo.toml b/Cargo.toml index 64696f57a28..b7dc03f87ac 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -57,6 +57,3 @@ url = "2.2.0" wasm-bindgen = { version = "=0.2.86", features = ["serde-serialize"] } wasm-bindgen-test = "0.3.33" base64 = "0.21.2" - -[patch.crates-io] -async-lsp = { git = "https://github.com/oxalica/async-lsp", rev = "09dbcc11046f7a188a80137f8d36484d86c78c78" } diff --git a/crates/lsp/Cargo.toml b/crates/lsp/Cargo.toml index 2611abd67dc..3cde18bfba9 100644 --- a/crates/lsp/Cargo.toml +++ b/crates/lsp/Cargo.toml @@ -19,7 +19,7 @@ noirc_frontend.workspace = true serde_json.workspace = true toml.workspace = true tower.workspace = true -async-lsp = { version = "0.0.4", default-features = false, features = ["omni-trait"] } +async-lsp = { version = "0.0.5", default-features = false, features = ["omni-trait"] } [dev-dependencies] tokio = { version = "1.0", features = ["macros"] } diff --git a/crates/nargo_cli/Cargo.toml b/crates/nargo_cli/Cargo.toml index 0486e2ee234..fd052e9dc95 100644 --- a/crates/nargo_cli/Cargo.toml +++ b/crates/nargo_cli/Cargo.toml @@ -34,16 +34,18 @@ serde.workspace = true serde_json.workspace = true thiserror.workspace = true tower.workspace = true -async-lsp = { version = "0.0.4", default-features = false, features = [ +async-lsp = { version = "0.0.5", default-features = false, features = [ "client-monitor", "stdio", "tracing", + "tokio" ] } const_format = "0.2.30" hex = "0.4.2" termcolor = "1.1.2" color-eyre = "0.6.2" tokio = { version = "1.0", features = ["io-std"] } +tokio-util = { version = "0.7.8", features = ["compat"] } # Backends acvm-backend-barretenberg = { version = "0.10.0", default-features = false } diff --git a/crates/nargo_cli/src/cli/lsp_cmd.rs b/crates/nargo_cli/src/cli/lsp_cmd.rs index 789ba6fe88d..ac15f4f8a9f 100644 --- a/crates/nargo_cli/src/cli/lsp_cmd.rs +++ b/crates/nargo_cli/src/cli/lsp_cmd.rs @@ -5,7 +5,6 @@ use async_lsp::{ }; use clap::Args; use noir_lsp::NargoLspService; -use tokio::io::BufReader; use tower::ServiceBuilder; use super::NargoConfig; @@ -30,7 +29,7 @@ pub(crate) fn run( let runtime = Builder::new_current_thread().enable_all().build().unwrap(); runtime.block_on(async { - let (server, _) = async_lsp::Frontend::new_server(|client| { + let (server, _) = async_lsp::MainLoop::new_server(|client| { let router = NargoLspService::new(&client); ServiceBuilder::new() @@ -42,7 +41,7 @@ pub(crate) fn run( .service(router) }); - // Prefer truely asynchronous piped stdin/stdout without blocking tasks. + // Prefer truly asynchronous piped stdin/stdout without blocking tasks. #[cfg(unix)] let (stdin, stdout) = ( async_lsp::stdio::PipeStdin::lock_tokio().unwrap(), @@ -50,10 +49,11 @@ pub(crate) fn run( ); // Fallback to spawn blocking read/write otherwise. #[cfg(not(unix))] - let (stdin, stdout) = (tokio::io::stdin(), tokio::io::stdout()); - - let stdin = BufReader::new(stdin); + let (stdin, stdout) = ( + tokio_util::compat::TokioAsyncReadCompatExt::compat(tokio::io::stdin()), + tokio_util::compat::TokioAsyncWriteCompatExt::compat_write(tokio::io::stdout()), + ); - server.run(stdin, stdout).await.map_err(CliError::LspError) + server.run_buffered(stdin, stdout).await.map_err(CliError::LspError) }) }