Skip to content

Commit 4457e28

Browse files
factorydroidechobt
authored andcommitted
fix(cli): allow specifying which LSP server to wait for in debug wait
Fixes bounty issue #1395 The --lsp-ready flag was hardcoded to only check for rust-analyzer. Added --lsp-server argument to allow specifying which LSP to wait for (e.g., typescript-language-server, pyright, gopls). Defaults to rust-analyzer for backward compatibility.
1 parent 6ac1a0f commit 4457e28

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

cortex-cli/src/debug_cmd.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1306,10 +1306,14 @@ async fn run_paths(args: PathsArgs) -> Result<()> {
13061306
/// Arguments for wait subcommand.
13071307
#[derive(Debug, Parser)]
13081308
pub struct WaitArgs {
1309-
/// Wait for LSP to be ready.
1309+
/// Wait for LSP to be ready (default: rust-analyzer).
13101310
#[arg(long)]
13111311
pub lsp_ready: bool,
13121312

1313+
/// LSP server to wait for (e.g., rust-analyzer, typescript-language-server, pyright, gopls).
1314+
#[arg(long, default_value = "rust-analyzer")]
1315+
pub lsp_server: String,
1316+
13131317
/// Wait for server to be ready.
13141318
#[arg(long)]
13151319
pub server_ready: bool,
@@ -1347,13 +1351,13 @@ async fn run_wait(args: WaitArgs) -> Result<()> {
13471351
let interval = Duration::from_millis(args.interval);
13481352

13491353
let (condition, success, error) = if args.lsp_ready {
1350-
// Wait for LSP - check if rust-analyzer or similar is available
1351-
let condition = "lsp_ready".to_string();
1354+
// Wait for LSP - check if the specified LSP server is available
1355+
let condition = format!("lsp_ready ({})", args.lsp_server);
13521356
let mut success = false;
13531357
let mut error = None;
13541358

13551359
while start.elapsed() < timeout {
1356-
let (available, _, _) = check_command_installed("rust-analyzer").await;
1360+
let (available, _, _) = check_command_installed(&args.lsp_server).await;
13571361
if available {
13581362
success = true;
13591363
break;
@@ -1362,7 +1366,7 @@ async fn run_wait(args: WaitArgs) -> Result<()> {
13621366
}
13631367

13641368
if !success {
1365-
error = Some("Timeout waiting for LSP".to_string());
1369+
error = Some(format!("Timeout waiting for LSP: {}", args.lsp_server));
13661370
}
13671371

13681372
(condition, success, error)

0 commit comments

Comments
 (0)