Skip to content

Commit

Permalink
Release LSP 2.0 (#8538)
Browse files Browse the repository at this point in the history
A small fix to surface an error in UI if there is a version mismatch in
turbo, as well as updating the LSP to support the new protocol version.

This also updates the lsp CI to use our setup-rust workflow rather than
hand rolling one

Co-authored-by: Nicholas Yang <[email protected]>
  • Loading branch information
arlyon and NicholasLYang committed Jun 24, 2024
1 parent a1007b6 commit e31046f
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 11 deletions.
12 changes: 5 additions & 7 deletions .github/workflows/lsp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,10 @@ jobs:
target: "aarch64-apple-darwin"
container-options: "--rm"
- host: ubuntu-latest
container: ubuntu:xenial
container-options: "--platform=linux/amd64 --rm"
container-setup: "apt-get update && apt-get install -y curl musl-tools sudo"
container-setup: "sudo apt-get update && sudo apt-get install -y curl musl-tools"
target: "x86_64-unknown-linux-musl"
setup: "apt-get install -y build-essential clang-5.0 lldb-5.0 llvm-5.0-dev libclang-5.0-dev"
setup: "sudo apt-get install -y build-essential"
- host: ubuntu-latest
container-options: "--rm"
target: "aarch64-unknown-linux-musl"
Expand Down Expand Up @@ -60,11 +59,10 @@ jobs:
uses: ./.github/actions/setup-capnproto

- name: Rust Setup
uses: actions-rs/toolchain@v1
uses: ./.github/actions/setup-rust
with:
profile: minimal
override: true
target: ${{ matrix.settings.target }}
github-token: ${{ secrets.GITHUB_TOKEN }}
targets: ${{ matrix.settings.target }}

- name: Build Setup
shell: bash
Expand Down
4 changes: 3 additions & 1 deletion crates/turborepo-lib/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ mod turbo_json;
pub use crate::{
child::spawn_child,
cli::Args,
daemon::{DaemonClient, DaemonConnector, Paths as DaemonPaths},
daemon::{
DaemonClient, DaemonConnector, DaemonConnectorError, DaemonError, Paths as DaemonPaths,
},
panic_handler::panic_handler,
run::package_discovery::DaemonPackageDiscovery,
};
Expand Down
28 changes: 27 additions & 1 deletion crates/turborepo-lsp/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
//! For more, see the [LSP specification](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/)
//! as well as the architecture documentation in `packages/turbo-vsc`.

#![feature(box_patterns)]
#![deny(clippy::all)]
#![warn(clippy::unwrap_used)]

Expand All @@ -29,7 +30,10 @@ use tower_lsp::{
Client, LanguageServer,
};
use turbopath::AbsoluteSystemPathBuf;
use turborepo_lib::{DaemonClient, DaemonConnector, DaemonPackageDiscovery, DaemonPaths};
use turborepo_lib::{
DaemonClient, DaemonConnector, DaemonConnectorError, DaemonError, DaemonPackageDiscovery,
DaemonPaths,
};
use turborepo_repository::{
discovery::{self, DiscoveryResponse, PackageDiscovery, WorkspaceData},
package_json::PackageJson,
Expand Down Expand Up @@ -90,6 +94,28 @@ impl LanguageServer for Backend {

let daemon = match daemon {
Ok(daemon) => daemon,
Err(DaemonConnectorError::Handshake(box DaemonError::VersionMismatch(message))) => {
self.client
.show_message(
MessageType::ERROR,
"Pre-2.0 versions of turborepo are not compatible with 2.0 or later \
of the extension. If you do not plan to update to turbo 2.0, please \
ensure you install the latest 1.0 version of the extension in this \
workspace.",
)
.await;
self.client
.log_message(
MessageType::ERROR,
format!("version mismatch when connecting to daemon: {}", message),
)
.await;

// in this case, just say we don't support any features
return Ok(InitializeResult {
..Default::default()
});
}
Err(e) => {
self.client
.log_message(
Expand Down
2 changes: 2 additions & 0 deletions packages/turbo-vsc/.vscodeignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
**/tsconfig.json
node_modules
out/artifacts
.turbo
**/*.vsix
2 changes: 1 addition & 1 deletion packages/turbo-vsc/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "turbo-vsc",
"displayName": "Turborepo LSP",
"version": "1.1.2",
"version": "2.0.0",
"description": "Tools and instant feedback for your build system",
"main": "out/main.js",
"publisher": "Vercel",
Expand Down
2 changes: 1 addition & 1 deletion pnpm-lock.yaml

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

0 comments on commit e31046f

Please sign in to comment.