diff --git a/crates/ty_server/src/message.rs b/crates/ty_server/src/message.rs index 038416aa46..8b21fcf52a 100644 --- a/crates/ty_server/src/message.rs +++ b/crates/ty_server/src/message.rs @@ -44,3 +44,11 @@ macro_rules! show_err_msg { crate::message::show_message(::core::format_args!($msg$(, $($arg)*)?).to_string(), lsp_types::MessageType::ERROR) }; } + +/// Sends a request to display a warning to the client with a formatted message. The warning is +/// sent in a `window/showMessage` notification. +macro_rules! show_warn_msg { + ($msg:expr$(, $($arg:tt)*)?) => { + crate::message::show_message(::core::format_args!($msg$(, $($arg)*)?).to_string(), lsp_types::MessageType::WARNING) + }; +} diff --git a/crates/ty_server/src/server.rs b/crates/ty_server/src/server.rs index e39a6a9682..36694eb2da 100644 --- a/crates/ty_server/src/server.rs +++ b/crates/ty_server/src/server.rs @@ -96,10 +96,20 @@ impl Server { anyhow::anyhow!("Failed to get the current working directory while creating a default workspace.") })?; - if workspaces.len() > 1 { - // TODO(dhruvmanila): Support multi-root workspaces - anyhow::bail!("Multi-root workspaces are not supported yet"); - } + let workspaces = if workspaces.len() > 1 { + let first_workspace = workspaces.into_iter().next().unwrap(); + tracing::warn!( + "Multiple workspaces are not yet supported, using the first workspace: {}", + &first_workspace.0 + ); + show_warn_msg!( + "Multiple workspaces are not yet supported, using the first workspace: {}", + &first_workspace.0 + ); + vec![first_workspace] + } else { + workspaces + }; Ok(Self { connection,