Skip to content

feat(lsp): add debugOverrideCommand option#22236

Open
shorwood wants to merge 1 commit into
rust-lang:masterfrom
shorwood:feat/lsp-debug-override-command
Open

feat(lsp): add debugOverrideCommand option#22236
shorwood wants to merge 1 commit into
rust-lang:masterfrom
shorwood:feat/lsp-debug-override-command

Conversation

@shorwood
Copy link
Copy Markdown
Contributor

@shorwood shorwood commented May 1, 2026

Closes #22128

Adds debugOverrideCommand for test and bench runnables so debug can use a different command from Run. This is needed for runners like nextest, where running a test and debugging a test require different command shapes.

The setting is opt-in. Existing overrideCommand, Cargo debug config generation, and matching launch.json entries keep their current behavior.

For reference, here's my setup with this PR active.

{
    "rust-analyzer.server.path": "$HOME/Workspaces/rust-analyzer/target/debug/rust-analyzer",
    "rust-analyzer.runnables.test.overrideCommand": [
        "nix",
        "shell",
        "nixpkgs#cargo-nextest",
        "-c",
        "cargo",
        "nextest",
        "run",
        "--config",
        "profile.dev.debug=2",
        "--package",
        "${package}",
        "${target_arg}",
        "${target}",
        "--",
        "${test_name}",
        "${exact}",
        "${include_ignored}"
    ],
    "rust-analyzer.runnables.test.debugOverrideCommand": [
        "nix",
        "shell",
        "nixpkgs#cargo-nextest",
        "-c",
        "cargo",
        "nextest",
        "run",
        "--config",
        "profile.dev.debug=2",
        "--package",
        "${package}",
        "${target_arg}",
        "${target}",
        "--debugger",
        "$HOME/.vscode/extensions/vadimcn.vscode-lldb-1.12.1/bin/codelldb-launch --connect 127.0.0.1:12345 --",
        "--",
        "${test_name}",
        "${exact}",
        "${include_ignored}"
    ],
    "rust-analyzer.runnables.extraEnv": {
        "CODELLDB_LAUNCH_CONFIG": "{ token: 'secret' }"
    },
    "lldb.rpcServer": {
        "host": "127.0.0.1",
        "port": 12345,
        "token": "secret"
    }
}

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 1, 2026
@rustbot

This comment has been minimized.

@shorwood shorwood force-pushed the feat/lsp-debug-override-command branch from a7a3150 to 0e6e8b5 Compare May 1, 2026 08:26
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented May 4, 2026

☔ The latest upstream changes (possibly #22284) made this pull request unmergeable. Please resolve the merge conflicts.

@@ -453,6 +453,15 @@ pub struct Runnable {
pub location: Option<lsp_types::LocationLink>,
pub kind: RunnableKind,
Copy link
Copy Markdown
Contributor

@ChayimFriedman2 ChayimFriedman2 May 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to also use RunnableCommand here? You can use serde(flatten).

View changes since the review

location: Some(location),
kind: lsp_ext::RunnableKind::Shell,
args: lsp_ext::RunnableArgs::Shell(runnable_args),
debug: None,
Copy link
Copy Markdown
Contributor

@ChayimFriedman2 ChayimFriedman2 May 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't we pass debug here too? It's even more useful for rust-project.json.

View changes since the review

executable_args,
environment: Default::default(),
}),
debug: None,
Copy link
Copy Markdown
Contributor

@ChayimFriedman2 ChayimFriedman2 May 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/// - `${include_ignored}`: always empty for benchmarks.
/// - `${executable_args}`: all of the above binary args bundled together
/// (includes `rust-analyzer.runnables.extraTestBinaryArgs`).
runnables_bench_debugOverrideCommand: Option<Vec<String>> = None,
Copy link
Copy Markdown
Contributor

@ChayimFriedman2 ChayimFriedman2 May 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

overrideDebugCommand makes more sense, the current name sounds like we're debugging the override.

View changes since the review

Comment thread editors/code/src/run.ts
Comment on lines +190 to +196
env: includeShellExtraEnv
? prepareEnv(
true,
runnableArgs.environment,
config.runnablesExtraEnv(runnable.label),
)
: prepareBaseEnv(true),
Copy link
Copy Markdown
Contributor

@ChayimFriedman2 ChayimFriedman2 May 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Custom rust-analyzer.runnables.test.overrideCommand breaks Debug runnable button

3 participants