Skip to content

Using Kalandra

Editor and CLI tools

Check, format and navigate native projects.

Use kalandra to create, install dependencies for, and compile projects; kalandra-check to diagnose source without running it; kalandra-fmt to format it; and kalandra-lsp for editor language services. The VS Code extension connects the native language server to the editor; it does not download or build that server for you.

The commands below assume main.k exists in the current directory and my-app is a project created with kalandra new my-app. They can be used independently.

Check source without executing it

bash
kalandra-check main.k
kalandra-check --project my-app/kalandra.toml
kalandra-check --diagnostics=json main.k

The checker reports syntax, name, type and shape diagnostics. JSON diagnostics include original module paths and UTF-16 editor ranges. --placement adds placement checking; it is not proof that every checked GPU program can be lowered or executed by an available device.

Format source

bash
kalandra-fmt main.k
kalandra-fmt --check main.k

The first command writes the formatted result to standard output; it does not edit main.k. --check returns success only when formatting is already canonical. Formatting uses two-space indentation while preserving meaningful tokens, comments and String spellings. Format Document in the editor applies a proposed edit to the open buffer.

Set up VS Code

Download kalandra-native.vsix and its SHA-256 sidecar from the same GitHub release as your toolchain. In VS Code, open the Command Palette and run Extensions: Install from VSIX, then select the downloaded file. The VSIX bundles the editor client and syntax grammar; it requires no Node.js, Bun or npm installation. Install the native compiler package separately, or use an editor-only package if you only need language services. Set Kalandra Native: Server Path in User Settings to the absolute kalandra-lsp path, or an executable name on PATH. Open a trusted local workspace with a .k file. The same VSIX works across supported architectures. On Windows ARM64, use native ARM64 VS Code and point Server Path to the ARM64 package's kalandra-lsp.exe.

If the project uses package mappings, set Kalandra Native: Project Path to its explicit TOML manifest. Relative paths require a single local workspace folder. Restart the server after manifest-content changes with Kalandra: Restart Native Language Server.

The server supplies diagnostics, hover, definition, references, rename, completion, signature help and formatting for supported local workspaces, including incomplete source. Lexical highlighting is not proof that a call is type-correct. Use Kalandra: Show Native Language Server Output for startup diagnostics.

Compile and inspect

bash
kalandra main.k -O2 -o program
kalandra main.k --emit-mlir program.mlir --emit-llvm program.ll -o program

The optional --emit-mlir and --emit-llvm flags write intermediate compiler representations for inspection; you do not need them to build an application. Source paths, project manifests and installed dependency files are protected against accidental output replacement. Use a package that includes your GPU backend when passing --target metal, --target vulkan or --target cuda.

Other code editors

Any editor with a Language Server Protocol client can launch kalandra-lsp directly over standard input/output. Associate .k files with Kalandra, configure the server command as the absolute path to kalandra-lsp and leave command arguments empty for ordinary relative-import projects. Do not launch the server through a shell. A native toolchain package supplies the executable and its resources; no JavaScript runtime is required.

For package mappings, pass --project followed by the absolute kalandra.toml path as two server arguments. Add --placement when you want CPU/GPU placement diagnostics. The client should support UTF-16 positions and apply workspace edits for rename and formatting. Editor-specific adapters are not bundled beyond VS Code. The server provides language services, not a debugger or build runner.

Report the toolchain version

Use the standalone --version option when reporting a bug or checking an installation. The compiler, checker, formatter, parser and language server share the native toolchain version. The VS Code extension has its own version.

bash
kalandra --version
kalandra-check --version
kalandra-fmt --version
kalandra-parse --version
kalandra-lsp --version