CrateStack Editor Tooling
This document records the current state of CrateStack editor support, how to use it locally, and the most useful follow-up work.Scope
CrateStack has two editor surfaces:- Rust files that consume
cratestack::include_schema!(...) .cstackschema files authored directly
include_schema! is a proc macro that expands relative to a real schema path.
.cstack support is intentionally split out into a standalone language server so basic schema authoring does not require a full host project checkout.
Current State
Implemented in this repo today:crates/cratestack-lspprovides a standalone language server for.cstackfilespackages/cratestack-vscodeprovides the VS Code extension wrapper that launchescratestack-lspcratestack-cli check --format jsonprovides machine-readable diagnostics for CI or editor fallback integrations- parser and semantic structures now preserve schema docs and source spans needed for editor features and generated Rust docs
include_schema!now emits Rust#[doc = "..."]attributes from schema-authored comments
.cstack editor features:
- diagnostics
- hover
- completion
- go-to-definition
- document symbols
- basic syntax highlighting through the bundled TextMate grammar
- relation-aware definition lookup inside
@relation(fields:[...],references:[...]) - narrower relation diagnostics that point at the bad relation token instead of only the whole declaration line
- schema
///docs now flow into generated Rust docs and rust-analyzer hovers when proc-macro expansion is enabled - procedure
/// @param name ...docs now flow into generated procedure argument types
- the parser still validates an initial schema subset rather than the full target grammar described across the broader docs
- Rust-side support is still project-dependent and requires real Cargo context
- the LSP does not yet implement rename, references, formatting, semantic tokens, or code actions
- the VS Code extension prefers a bundled server binary when one is staged, but it does not yet auto-download release binaries
Rust Setup In VS Code
For Rust consumers ofinclude_schema!, use rust-analyzer and point it at the workspace or workspaces that actually build the schema consumer.
Recommended workspace settings for this repo:
- this repo root is not a single Cargo workspace
- generated Rust APIs come from proc-macro expansion
- the generated
cratestack_schemamodule only exists when rust-analyzer can build the real consumer crate
.cstack Setup In VS Code
The intended path for .cstack files is the cratestack-vscode extension plus cratestack-lsp.
Local development flow:
- From
cratestack/, build the language server withcargo build -p cratestack-lsp. - From
cratestack/packages/cratestack-vscode, runpnpm installif needed. - Install or run the extension.
- If the server binary is not on
PATHand not bundled into the extension package, setcratestack.lsp.pathto the built binary.
cratestack.lsp.path: path to thecratestack-lspbinarycratestack.lsp.args: extra args passed through to the server
- bundled binary under
server/<platform>/cratestack-lsp - configured
cratestack.lsp.path cratestack-lsponPATH
CLI Fallback And CI
For machine-readable schema validation outside the editor:- CI validation
- fallback editor integrations outside VS Code
- smoke-testing parser and semantic diagnostics without starting the LSP
Schema Docs And Generated Rust Docs
Schema-authored comments now serve both schema authors and Rust consumers. Supported today:- leading
///comments on declarations and fields /// @param name ...docs for procedure arguments- proc-macro emission of Rust
#[doc = "..."]attributes for generated models, fields, inputs, and procedure modules
.cstackauthors reading schemas- Rust users reading generated API docs and hovers
- future richer hover content in the
.cstacklanguage server
Packaging And Release Flow
The current extension packaging model is intentionally thin.cratestack-vscode contributes the language registration and launches cratestack-lsp; the heavy logic stays in the Rust binary.
Current release flow:
- Build the release server with
cargo build --release -p cratestack-lsp. - Stage the binary into
packages/cratestack-vscode/server/<platform>/withpnpm run stage-server. - Package the extension with
pnpm run package:vsix.
vsce --no-dependencies because the extension ships a small JavaScript wrapper plus the staged server binary rather than relying on npm dependency scanning to decide runtime contents.
Verification In Repo
Covered today:- parser tests for docs, spans, and related regressions
- LSP tests for hover, definitions, symbols, and relation diagnostics
- extension package tests for server path resolution
- VS Code extension-host smoke tests for activation and bundled server launch
- Rust workspace tests for the underlying crates
Future Improvements
Highest-value follow-up work:- Add code actions for common relation mistakes, especially missing
fields/referencestargets and simple typo recovery. - Add semantic tokens so schema highlighting is less dependent on the TextMate grammar alone.
- Add rename, find-references, and document-wide symbol search on top of the precise spans now carried in the schema model.
- Add stronger extension-host end-to-end tests that assert definition, hover, and diagnostics through the actual VS Code APIs.
- Reduce VSIX size with a
filesallowlist or.vscodeignoreand add missing package metadata such as repository and license fields.
- Extend the parser and semantic model toward the full target grammar described in the broader PRD and ADR docs.
- Add richer relation-aware validation so relation diagnostics can reason about more mismatches before code generation.
- Expose more stable editor-oriented library surfaces from parser and semantic crates instead of keeping some logic narrowly embedded in the current LSP layer.
- Improve multi-platform release packaging so extension artifacts can be produced and verified more systematically across supported targets.
- Add non-VS-Code editor integration paths using the standalone
cratestack-lspbinary.
- Formatting support for
.cstackonce the schema grammar and style expectations stabilize. - Auto-download or release-channel discovery for
cratestack-lspbinaries instead of requiring either a bundled server or manual path setup. - More workspace-aware Rust and schema cross-navigation if future architecture needs symbol links between generated Rust surfaces and original schema declarations.