chmp / cargo-wop

Run cargo on Rust source files without setting up a project
MIT License
1 stars 1 forks source link

Add support for rust-analyzer via rust-project.json #7

Open chmp opened 4 years ago

chmp commented 4 years ago

With a rust-project.json file rust-analyzer should be able to handle cargo-wop projects. The format is documented here.

chmp commented 3 years ago

Get the current sysroot using rustc --print sysroot and append lib/rustlib/src/rust/library

The .vscode/settings.json file should read:

{
    "rust-analyzer.linkedProjects": [
        {
            "sysroot_src": "$(rustc --print sysroot)/lib/rustlib/src/rust/library",
            "crates": [
                {
                    "root_module": "$file",
                    "edition": "2018",
                    "deps": [],
                },
            ]
        }
    ]
}

however deps are missing + normal crates are no longer detected.

Alternative use path generated manifest:

{
    "rust-analyzer.linkedProjects": [
        "path from $(cargo wop locate-project $file)"
    ]
}

however, this also does not seem to work.