feat: generate rust-project.json for LSP
Add a CMake module that writes rust-project.json on every configure so rust-analyzer can resolve the no-Cargo crate layout, sysroot crates, and proc-macro attributes without Cargo. Co-Authored-By: qwen (lmstudio/qwen3.8-27b@q3_k_xl): LSP setup
This commit is contained in:
@@ -19,6 +19,7 @@ The project contains:
|
||||
entry helpers
|
||||
- `macros/src/lib.rs`: host-side `#[rslibc_macros::main]` attribute macro
|
||||
- `runtime/main.rs`: minimal example entry point
|
||||
- `cmake/RustLSP.cmake`: generates `rust-project.json` for rust-analyzer
|
||||
- `CMakeLists.txt`: direct `rustc` library, macro, and executable commands
|
||||
|
||||
## No-Std Design
|
||||
@@ -112,6 +113,19 @@ Run it on Windows:
|
||||
- `RelWithDebInfo`: `-C opt-level=3 -C debuginfo=2`
|
||||
- Other or unset configurations: `-C opt-level=0 -C debuginfo=2`
|
||||
|
||||
## LSP
|
||||
|
||||
rust-analyzer works without Cargo through a generated manifest:
|
||||
|
||||
- `cmake/RustLSP.cmake` runs on every configure and writes
|
||||
`rust-project.json` (git-ignored) describing the three crates and the
|
||||
toolchain sysroot, so `core`, `alloc`, and proc-macro attributes resolve.
|
||||
- Requires the rustup components:
|
||||
`rustup component add rust-analyzer rust-src`.
|
||||
- Open the repository root in the editor so rust-analyzer picks up
|
||||
`rust-project.json`. Re-run CMake configure after changing the crate
|
||||
layout or switching toolchains.
|
||||
|
||||
## Verification
|
||||
|
||||
After changing the source or build configuration, run a clean release build
|
||||
|
||||
Reference in New Issue
Block a user