Skip to content

Add rust analyzer configuration to discover Rust projects #96

@iinuwa

Description

@iinuwa

Because we're using Meson as our build system (mostly), we don't get automatic discovery of Rust projects in rust-analyzer. rust-analyzer also does not share the same Cargo home as Meson, so everything gets compiled twice. It especially hurts when modifying lock files, since everything gets downloaded twice.

In my local .vscode/settings.json file, I have the following to make rust-analyzer work properly:

{
    "rust-analyzer.cargo.extraEnv": {
        "CARGO_HOME": "/home/isaiah/Development/rust/linux-webauthn-platform-api/build/cargo-home"
    },
    "rust-analyzer.runnables.extraEnv": {
        "CARGO_HOME": "/home/isaiah/Development/rust/linux-webauthn-platform-api/build/cargo-home"
    },
    "rust-analyzer.check.extraEnv": {
        "CARGO_HOME": "/home/isaiah/Development/rust/linux-webauthn-platform-api/build/cargo-home"
    },
    "rust-analyzer.server.extraEnv": {
        "CARGO_HOME": "/home/isaiah/Development/rust/linux-webauthn-platform-api/build/cargo-home"
    },
    "rust-analyzer.linkedProjects": [
        "credentialsd-common/Cargo.toml",
        "credentialsd-ui/Cargo.toml",
        "credentialsd/Cargo.toml",
    ],
}

I believe there are files you can put in a repository that will configure rust-analyzer manually. We should make one of those and at least put in the linkedProjects key in there. (I don't know if the CARGO_HOME will be useful if users don't use build for their build directory.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    buildImprovements and fixes to build system, CI, etc.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions