Skip to content

Rust LSP #405

Closed
Closed

Description

@casualjim

Just opening for discussion, PR is incoming

Rust seems to need a different implementation strategy than the current clean-room resolvers. For many languages, codebase-memory can reconstruct enough type and import semantics from tree-sitter plus per-language registries. For Rust, that approach is likely to fail on the cases users care about most: macro_rules!, derive/proc macros, build-script generated code, cfg/features, trait dispatch, associated functions, generics, and cross-crate workspace resolution. To avoid false graph edges, I think we should lean on rust-analyzer semantics directly rather than trying to reimplement that machinery in C.

The proposed shape is a small, vendorable Rust library built on pinned ra_ap_* rust-analyzer crates, exposing a stable generic C ABI. The C indexer would continue owning the graph pipeline and mapping, while the Rust library would load a Cargo workspace once, resolve call targets in batches, and return source/target file/range evidence with confidence and provenance. External/std/core/unresolved/ambiguous targets would produce diagnostics or no edge, not guessed edges. Proc macros and build scripts would be explicit configuration choices, because they are necessary for accuracy in real Rust projects but have security/performance implications.

I have a prototype along these lines already: generic RustAnalyzer* ABI, generated C header, prefix install/pkg-config smoke test, RA-backed fixture coverage for direct/method/trait/generic/macro-related calls, and conservative no-edge handling for unsafe/generated ambiguity. The intent is to contribute this as an integration path rather than force Rust-specific internals into codebase-memory: CBM adapts its existing file/call/definition records into the ABI, receives resolved call evidence back, and inserts graph edges only when the returned target maps to a stable local/workspace definition.

To that end I created this: https://github.com/casualjim/cbm-rust-analyzer

Activity

  1. DeusData commented on Jun 1, 2026

    @DeusData
    Owner

    Hey @casualjim, thanks for sharing your idea and project. In general I agree with you. The whole idea of "Hybrid LSP" is to basically catch the weak spots of the tree-sitter method. In general I prefer having everything bundled together in my own setup using the architecture provided. An Rust Hybrid LSP is already on the way, just needs some polishing. It is a question of weeks (like sub 2) than months. In general the "integration" path is interesting, but not sure if the project is mature enough for this route. I will post here again once the Rust Hybrid LSP lands. Maybe you can then test it out and give some feedback how it works for you

  2. casualjim commented on Jun 1, 2026

    @casualjim
    ContributorAuthor

    oic, sure I can test it. I'm curious how you did it

    I just kept my thing as a separate repo to get feedback before I worked out how to vendor it. It's already tested on macro heavy projects like clap etc.

  3. added
    enhancementNew feature or request
    parsing/qualityGraph extraction bugs, false positives, missing edges
    on Jun 6, 2026
  4. DeusData commented on Jun 11, 2026

    @DeusData
    Owner

    Hey @casualjim, 0.8.0 is out with the Rust LSP Hybrid. Can you maybe check it out for completeness? Would be great to get your feedback

  5. added
    awaiting-reporterWaiting on the reporter for info/repro; stale bot will warn then close
    priority/backlogValuable contribution, lower scheduling urgency; review when maintainer capacity opens.
    on Jun 23, 2026
  6. added this to the 0.9.2-rc milestone on Jul 8, 2026
  7. removed
    awaiting-reporterWaiting on the reporter for info/repro; stale bot will warn then close
    on Jul 10, 2026
  8. added
    awaiting-reporterWaiting on the reporter for info/repro; stale bot will warn then close
    on Aug 20, 2026
  9. github-actions commented on Aug 20, 2026

    @github-actions

    Thanks for the report! To move this forward we need a bit more so we can reproduce it ourselves:

    • the codebase-memory-mcp --version you're on
    • the exact steps or command you ran
    • a public repo (or a small dummy snippet) that shows the problem — please don't paste proprietary code

    Once that's here we'll pick it straight back up. Heads-up: issues left awaiting-reporter are automatically closed after a few weeks of silence, but a comment reopens the door anytime.

  10. github-actions commented on Sep 11, 2026

    @github-actions

    This issue has been waiting on more information for 21 days (a version, exact steps, or a public repro), so it's now marked stale. It will not be closed automatically — a maintainer reviews stale issues by hand. Adding a comment with the details clears the label and puts it straight back in the queue. We're happy to pick it back up the moment we can reproduce it.

  11. added
    staleNo activity after an info request; will be closed soon
    on Sep 11, 2026
  12. DeusData commented on Oct 25, 2026

    @DeusData
    Owner

    Thank you for the Rust integration proposal and the offer to test. If you have since compared the bundled implementation against your macro/workspace cases, a short account of the remaining gaps would be useful. The separate rust-analyzer integration direction still needs a maintainer decision.

  13. removed
    staleNo activity after an info request; will be closed soon
    on Oct 26, 2026
  14. casualjim commented on Nov 2, 2026

    @casualjim
    ContributorAuthor

    I have long ago stopped using my own work around and I'm relying on your implementation directly. But I never let you know. For me this is good. lgtm

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    awaiting-reporterWaiting on the reporter for info/repro; stale bot will warn then closeenhancementNew feature or requestparsing/qualityGraph extraction bugs, false positives, missing edgespriority/backlogValuable contribution, lower scheduling urgency; review when maintainer capacity opens.

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions