Skip to content

Commit

Permalink
chore: Bump async-lsp to v0.0.5 (#2186)
Browse files Browse the repository at this point in the history
* WIP: async-lsp updates

* chore: bump `async-lsp` commit

* chore: bump to `async-lsp` v0.0.5

* chore: spelling

---------

Co-authored-by: Tom French <tom@tomfren.ch>
  • Loading branch information
phated and TomAFrench authored Aug 9, 2023
1 parent e657ecc commit f74cbec
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 17 deletions.
22 changes: 17 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
2 changes: 1 addition & 1 deletion crates/lsp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
4 changes: 3 additions & 1 deletion crates/nargo_cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
14 changes: 7 additions & 7 deletions crates/nargo_cli/src/cli/lsp_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use async_lsp::{
};
use clap::Args;
use noir_lsp::NargoLspService;
use tokio::io::BufReader;
use tower::ServiceBuilder;

use super::NargoConfig;
Expand All @@ -30,7 +29,7 @@ pub(crate) fn run<B: Backend>(
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()
Expand All @@ -42,18 +41,19 @@ pub(crate) fn run<B: Backend>(
.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(),
async_lsp::stdio::PipeStdout::lock_tokio().unwrap(),
);
// 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)
})
}

0 comments on commit f74cbec

Please sign in to comment.