Skip to content
Kavachकवच

Editor Setup

● Intermediate5 minBefore this: Install

The Kavach extension for VS Code, Cursor and other VS Code-based editors colors code and shows errors as you type.

What it gives

  • Colors for .kav files, and for ```kavach blocks inside Markdown.
  • Errors and warnings as you type, with the same messages as kavach check. The check runs on its own, so hover, completion and colors answer at once while a file is checked, and a check of text you have since changed is never shown.
  • Hover to see a value's type; F12 to go to where a name is declared.
  • Completion: the names in scope, and after a . the value's fields and methods.
  • Names colored by where they come from: what a use brings in is lavender, the language's own methods (xs.push(2), s.len()) gold, and your own methods your theme's color. So a call shows whether it is the language's or the program's.
  • Quick fixes:
    • "Mark helper as a gpu fn", when a gpu fn calls a plain function that fits the GPU's rules.
    • Every fix that kavach fix makes, one at a time: "Remove this arm", "Remove this branch", "Write ==", "Declare it with let", "Add uses Fs.read" and the rest.
    • Two that may not be what you meant, so they are offered, never made for you: "Change to total" on a misspelled name, and "Change the total declared above" on a let that hides another.
    They find the code in the compiled program, not by matching text, so each changes exactly what its message is about.
  • Comment toggling, bracket matching, and /// continuing on Enter.

Install it

The extension isn't on the Marketplace yet: it is built from the repository, with no npm needed.

terminal
cargo build --release -p kavach-cli
sh scripts/package-vscode.sh
code --install-extension .kavach/kavach-vscode-0.2.0.vsix
  1. The first line builds kavach (it needs Rust). On Windows, package with powershell -File scripts/package-vscode.ps1.
  2. If kavach isn't on your PATH, set Kavach: Path in the settings to the program the first line built.
  3. Reload the window (Ctrl+Shift+P, Developer: Reload Window).
  4. Check it: write const x: Int = "text" in a .kav file, and a red line appears.