An IntelliJ IDEA plugin for the Typst language, built on typst-syntax, endive, tinymist and lsp4ij.
- Syntax Highlighting — Compiles
typst-syntaxto WASM, then converts to Java classes via Endive for native-level syntax highlighting - PSI Tree — Full IntelliJ PSI tree (lexer, parser, element types) backed by the official Typst parser
- LSP Integration — Language intelligence via the
tinymistlanguage server: completions, diagnostics, hover, go-to-definition, code lens, folding, signature help, and more - Live Preview — Real-time rendering via JCEF browser, powered by tinymist's preview protocol
- Export to PDF — Export Typst documents to PDF via tinymist
- Language Injection — Automatic IDE support injection for embedded languages in code blocks
- LSP Discovery — Supports three strategies to locate tinymist: auto-download, system PATH lookup, and manual configuration
┌────────────────────────────────────────────────────────┐
│ IntelliJ IDEA Plugin │
│ ┌──────────────┐ ┌───────────┐ ┌───────────────────┐ │
│ │ PSI / Lexing │ │ Preview │ │ LSP (via LSP4IJ) │ │
│ │ (WASM/JVM) │ │ (JCEF) │ │ (tinymist proc) │ │
│ └──────┬───────┘ └───────────┘ └─────────┬─────────┘ │
└─────────┼─────────────────────────────────┼────────────┘
│ │
▼ ▼
┌───────────────┐ ┌──────────────────┐
│ typalize.wasm │ │ tinymist LSP │
│ (typst-syntax)│ │ (external proc) │
└───────────────┘ └──────────────────┘
-
Rust —
crates/typalize/— Wrapstypst-syntax(v0.15.0) as acdylibtargetingwasm32-wasip1. Exposes C ABI functions (tokenize,parse,version) using BCS (Binary Canonical Serialization) for efficient data transfer. -
WASM → Java Bridge — Uses Endive (an endive-based WASM-to-Java toolchain) to compile the WASM binary to Java bytecode. The
Coreinterface providestokenize(),parse(), andversion()methods directly callable from JVM languages. -
Plugin — Consumes the wrapped Java API for lexing (
TypstLexer) and parsing (TypstParser), building a full PSI tree. LSP features are handled by LSP4IJ delegating to an externaltinymistprocess. Preview uses JCEF to connect to tinymist's preview endpoint.
- JDK 25 (required by IntelliJ IDEA 2026.1+)
- Rust nightly (with
wasm32-wasip1target)
# 1. Build typst-syntax
cargo xtask generate
# 2. Build and run the plugin
./gradlew runIdeCompiles typst-syntax (Rust) into JVM bytecode.
| Step | Command | Description |
|---|---|---|
| 1. Install WASM tools | cargo xtask get-wasm-tool <type> |
Download WASI SDK, wasmtime, or binaryen to .tools/ |
| 2. Generate serialization code | cargo xtask generate-reflection-code |
Run gen_reflection binary to produce serde-reflection YAML → generate Java BCS serialization code |
| 3. Build WASM | cargo xtask build-wasm |
Cross-compile typalize crate to wasm32-wasip1 using WASI SDK |
| 4. Copy WASM | cargo xtask copy-wasm |
Copy .wasm to src/main/resources/wasm/ |
| 5. Optimize WASM | cargo xtask optimize-wasm |
Run wasm-opt -Oz --strip-debug via binaryen |
| 6. Generate Java class | cargo xtask generate-java-class |
Run Endive compiler (./gradlew endiveCompile) + code formatter (./gradlew spotlessApply) |
cargo xtask generateThis runs all 6 steps above sequentially.
┌──────────────────────────┐
│ typst-syntax (Rust) │
│ crate: typalize │
│ (cdylib, rlib) │
└───────────┬──────────────┘
│ cargo build --target wasm32-wasip1
▼
┌──────────────────────────┐
│ typalize.wasm │
│ (wasm32-wasip1) │
└───────────┬──────────────┘
│ wasm-opt (binaryen)
▼
┌──────────────────────────┐
│ typalize.wasm │
│ (optimized) │
└───────────┬──────────────┘
│ Endive compiler
▼
┌───────────────────────────────────┐
│ - Generates code (Endive WASM │
│ and BCS) │
│ - Wraps into a general API │
│ - WASM environment init │
│ - Load WASM module │
│ - Serialize parameters │
│ - Call functions │
│ - Deserialize results │
└──────────────────┬────────────────┘
│ compile
▼
┌──────────────────────────────────┐
│ IntelliJ IDEA Plugin │
│ - TypstLexer → tokenize() │
│ - TypstParser → parse() │
│ - LSP4IJ → tinymist │
└──────────────────────────────────┘
# Run the plugin in a development IDE instance
./gradlew runIde
# Run tests
./gradlew test
# Run verifications
./gradlew verifyPlugin
# Build the plugin distribution
./gradlew buildPlugin| Tool | Resource Type | Version |
|---|---|---|
| WASI SDK | WasiSdk |
33.0 |
| Wasmtime | Wasmtime |
v46.0.1 |
| Binaryen | Binaryen |
version_130 |
Download URLs can be overridden via environment variables: WASI_SDK_URL, WASMTIME_URL, BINARYEN_URL.
.
├── crates/
│ ├── typalize/ # Rust WASM crate (typst-syntax wrapper)
│ │ ├── src/
│ │ │ ├── lib.rs # C ABI exports
│ │ │ ├── envelope.rs # Serializable types (Token, ASTNode, …)
│ │ │ ├── syntax.rs # AST traversal (Flatten, ASTBuilder)
│ │ │ └── util.rs # UTF-16 mapping, memory management
│ │ └── Cargo.toml
│ └── enum-mirror/ # Proc-macro crate (enum mirroring)
├── xtask/ # Build automation (cargo xtask)
│ ├── main.rs # CLI dispatch
│ ├── task.rs # Build step implementations
│ ├── util.rs # Shared utilities (download, extraction, etc.)
│ └── Cargo.toml
├── buildSrc/ # Custom Gradle build logic
│ └── src/main/kotlin/
│ └── EndiveCompilerTask.kt # Endive Gradle task
├── src/
│ ├── main/
│ │ ├── kotlin/…/typilot/ # Plugin source code
│ │ ├── java/ # Java code
│ │ └── resources/ # Plugin resources
│ └── test/ # Tests
├── build.gradle.kts # Gradle build script
├── Cargo.toml # Rust workspace root
├── rust-toolchain.toml # Rust toolchain configuration
└── gradle.properties # Plugin metadata & versions