{"id":31706931,"url":"https://github.com/ethowitz/cargo-subspace","last_synced_at":"2025-10-11T01:00:18.390Z","repository":{"id":318369976,"uuid":"1069841356","full_name":"ethowitz/cargo-subspace","owner":"ethowitz","description":"A tool to make rust-analyzer speedier when working with very large cargo workspaces","archived":false,"fork":false,"pushed_at":"2025-10-06T18:42:29.000Z","size":71,"stargazers_count":35,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-10-06T20:42:10.104Z","etag":null,"topics":["cargo","devtools","lsp","neovim","rust","rust-analyzer","tools","vscode"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ethowitz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-10-04T18:17:27.000Z","updated_at":"2025-10-06T20:03:01.000Z","dependencies_parsed_at":"2025-10-06T20:42:23.521Z","dependency_job_id":null,"html_url":"https://github.com/ethowitz/cargo-subspace","commit_stats":null,"previous_names":["ethowitz/cargo-subspace"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/ethowitz/cargo-subspace","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ethowitz%2Fcargo-subspace","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ethowitz%2Fcargo-subspace/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ethowitz%2Fcargo-subspace/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ethowitz%2Fcargo-subspace/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ethowitz","download_url":"https://codeload.github.com/ethowitz/cargo-subspace/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ethowitz%2Fcargo-subspace/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279000736,"owners_count":26082862,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-08T02:00:06.501Z","response_time":56,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cargo","devtools","lsp","neovim","rust","rust-analyzer","tools","vscode"],"created_at":"2025-10-08T23:47:02.474Z","updated_at":"2025-10-10T00:01:54.850Z","avatar_url":"https://github.com/ethowitz.png","language":"Rust","readme":"# cargo subspace\n\n\u003cdiv align=\"center\"\u003e\n\n![A retro-futuristic computer from Star Trek with three waveforms overlaid on grids. The top left reads \"TRANSPECTRAL ANALYSIS COMPLETE\", and the bottom right reads \"SUBSPACE COM WAVE 0118\". There some small, illegible text to the left of the wave forms.](subspace.jpg)\n\n\u003c/div\u003e\n\nA tool that forces rust-analyzer to lazily index crates in the workspace as you open new files. It\nis useful if you have a very large cargo workspace (think hundreds of crates) and you find that\nrust-analyzer can be slow or laggy as a result.\n\n- [A note](#a-note)\n- [What the heck is this](#what-the-heck-is-this)\n- [Caveats](#caveats)\n- [Installation](#installation)\n  - [VSCode](#vscode)\n  - [neovim](#neovim)\n  - [Kate](#kate)\n- [Troubleshooting/Debugging](#troubleshootingdebugging)\n\n## A note\n\n**I want to preface all of this by saying that rust-analyzer is an amazing project, and I am\neternally grateful to the many people who contribute to it! It makes developing rust code a breeze,\nand it has surely significantly contributed to Rust's widespread adoption.**\n\n## What the heck is this\n\nThis tool exists to improve the rust-analyzer experience for very large cargo workspaces.\nCargo workspaces can contain a (theoretically) unbounded number of crates. Many organizations\nprefer to maintain a single cargo workspace (e.g. in a monorepo) to keep dependency versions\nconsistent across different services or libraries and simplify tooling. However, rust-analyzer\nindexes the crates in the cargo workspace pretty eagerly, which can take quite a long time.\n`check.workspace = false` and `cachePriming.enable = false` can help make things a bit lazier,\nbut in my experience, they don't solve the problem entirely. Even after indexing is finished,\ncertain actions, like autocomplete and and finding references to symbols, can be laggy due to the\nvery large dependency graph.\n\nRather than allowing rust-analyzer to discover all the crates in the workspace at startup, this\ntool tells rust-analyzer about the crates in your workspace selectively as you open new files. It\ninvokes `cargo metadata` to get the dependency graph for the workspace and then prunes the graph\nsuch that only 1) the crate that owns the current file and 2) that crate's dependencies remain in\nthe graph. This is supported by rust-analyzer's \"rust-project.json\" feature, which allows\nrust-analyzer to use third party build tools (e.g. bazel or buck) to discover crates in your\nproject. (This project still uses cargo under the hood, but it integrates into rust-analyzer\nthrough this path.)\n\n## Caveats\n\nNote that, because crates are indexed lazily as you open source code files, you will not be able to\ncorrectly perform any actions that require knowledge of all of the **dependents** of the current\ncrate (that is, the crates in your workspace that *depend on* the current crate). Some examples\ninclude:\n\n- Finding references to symbols (e.g. functions, types, etc.) defined in the current crate in\n  crates that *depend on* the crate (unless you've already opened a file from the dependent crate,\n  which means it is already known to rust-analyzer)\n- Performing an LSP-powered rename (instances of the symbol in unloaded crates will not be\n  correctly renamed, since rust-analyzer has not indexed those crates)\n\nAdditionally, symbols defined in unloaded crates will not appear in a symbol search.\n\n## Installation\n\nFirst, make sure that the `rust-src` component is installed for your rust toolchain. This downloads\nthe source code for the crates built-in to rust (e.g. `std` and `core`) so rust-analyzer can\nproperly index them.\n\n```sh\nrustup component add rust-src\n```\n\nThen:\n\n```sh\ncargo install --locked cargo-subspace\n```\n\nNext, you need to update the configuration that gets passed to rust-analyzer by your editor (this\nstep is editor-specific). I've tested it with VSCode, neovim, and Kate, but theoretically, it\nshould work with any editor that has LSP support.\n\n### VSCode\n\nAdd the following to your `settings.json`:\n\n```json\n{\n  \"rust-analyzer.workspace.discoverConfig\": {\n    \"command\": [\n        \"cargo-subspace\",\n        \"discover\",\n        \"{arg}\"\n    ],\n    \"progressLabel\": \"cargo-subspace\",\n    \"filesToWatch\": [\n        \"Cargo.toml\"\n    ]\n  },\n  \"rust-analyzer.check.overrideCommand\": [\n    \"cargo-subspace\",\n    \"check\", // You can also use \"clippy\" here\n    \"$saved_file\",\n  ],\n}\n```\n\n### neovim\n\nThese settings should be set wherever you configure your LSP servers in your neovim config. I use \nthe great [rustaceanvim](https://github.com/mrcjkb/rustaceanvim) plugin, but these settings can\nalso be set via lspconfig.\n\n```lua\n[\"rust-analyzer\"] = {\n  check = {\n    overrideCommand = {\n      \"cargo-subspace\",\n      \"clippy\",\n      \"$saved_file\",\n    },\n  },\n  workspace = {\n    discoverConfig = {\n      command = {\n        \"cargo-subspace\",\n        \"discover\",\n        \"{arg}\",\n      },\n      progressLabel = \"cargo-subspace\",\n      filesToWatch = {\n        \"Cargo.toml\",\n      },\n    },\n  },\n}\n```\n\n### Kate\n\nKate doesn't seem to include the typical cargo home (`\u003cYOUR HOME DIRECTORY\u003e/.cargo/bin`) directory\non the `PATH` it passes to rust-analyzer, so you'll need to pass the cargo home path to\n`cargo-subspace` directly and provide an absolute path to the `cargo-subspace` binary itself.\nIn the example below, `\u003cCARGO HOME\u003e` should be substituted for an absolute path to the directory\nin which your cargo binaries reside (usually, this is `\u003cYOUR HOME DIRECTORY\u003e/.cargo/bin`).\n\nThese settings should be specified in `Settings --\u003e LSP Client --\u003e User Server Settings`:\n\n```json\n{\n  \"servers\": {\n    \"rust\": {\n      \"useWorkspace\": false,\n      \"initializationOptions\": {\n        \"check\": {\n          \"allFeatures\": true,\n          \"overrideCommand\": [\n            \"\u003cCARGO HOME\u003e/cargo-subspace\",\n            \"--cargo-home=\u003cCARGO HOME\u003e\",\n            \"clippy\",\n            \"$saved_file\"\n          ]\n        },\n        \"workspace\": {\n          \"discoverConfig\": {\n            \"command\": [\n              \"\u003cCARGO HOME\u003e/cargo-subspace\",\n              \"--cargo-home=\u003cCARGO HOME\u003e\",\n              \"discover\",\n              \"{arg}\"\n            ],\n            \"progressLabel\": \"cargo-subspace\",\n            \"filesToWatch\": [\n              \"Cargo.toml\"\n            ]\n          }\n        }\n      }\n    }\n  }\n}\n```\n\nNote the `\"useWorkspace\": false` line; this is required!\n\n## Troubleshooting/Debugging\n\nIf you run into trouble, please feel free to open an issue with the following:\n\n- A detailed description of the problem, including steps to reproduce\n- Your rust toolchain version\n- Your `cargo-subspace` version\n- Verbose logs from the errant invocation of this tool (you can collect verbose logs by\n  running `cargo-subspace` with the `--verbose` flag). By default, logs are stored in\n  `$HOME/.local/state/cargo-subspace/cargo-subspace.log`\n\nYou may also feel free to open an issue if you have a feature request. Provided the feature makes\nsense and is not too involved, I would be happy to consider it. I'll also accept pull requests if\nyou're feeling inspired to implement it yourself.\n\n**NOTE:** This project is currently untested on Windows. Please feel free to test it and tell me\nabout your experience!\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fethowitz%2Fcargo-subspace","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fethowitz%2Fcargo-subspace","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fethowitz%2Fcargo-subspace/lists"}