VS Code Extension for Turmeric

The Turmeric VS Code extension provides syntax highlighting for .tur files (both standard S-expression syntax and sweet-exp indentation-based syntax), document formatting via tur format, and a language client that launches the compiler's built-in language server (tur lsp).

The extension lives in vscode-syntax-ext/ at the repo root.

Installation

From source

cd vscode-syntax-ext

# Option A: copy to extensions directory
mkdir -p ~/.vscode/extensions/turmeric-syntax-0.2.0
cp -r * ~/.vscode/extensions/turmeric-syntax-0.2.0/

# Option B: symlink for live editing
ln -s "$(pwd)" ~/.vscode/extensions/turmeric-syntax-dev

Reload VS Code after either option.

From a packaged .vsix

Build the package (see "Building a .vsix" below), then:

code --install-extension turmeric-syntax-0.2.0.vsix

Features

Once installed, any .tur file is automatically highlighted:

Bracket and indentation support

Formatting

The extension registers a document formatter that pipes the buffer through tur format (requires tur on PATH). Use the standard Format Document command, the extension's "Format Turmeric Document" command, or enable editor.formatOnSave for the [turmeric] language.

Language server

The extension launches tur lsp for .tur files (diagnostics, hover docs, go-to-definition). The turmeric.serverPath setting (default "tur") points it at the executable to use.

{
  "[turmeric]": {
    "editor.tabSize": 2,
    "editor.insertSpaces": true,
    "editor.formatOnSave": false
  }
}

Scope names (for theme customization)

Scope Matches
keyword.control.turmeric if, match, loop, while, etc.
keyword.definition.turmeric defn, defmacro, defstruct, etc.
keyword.type.turmeric :int, :cstr, type annotations
keyword.effect.turmeric defeffect, handle, perform
support.function.builtin.turmeric Built-in functions
entity.name.function.turmeric User-defined function names
constant.numeric.integer.turmeric Integer literals
constant.numeric.float.turmeric Float literals
constant.language.boolean.true.turmeric #t
constant.language.boolean.false.turmeric #f
constant.character.turmeric Character literals
string.quoted.double.turmeric String literals
comment.line.semicolon.turmeric Line comments
comment.block.turmeric Block comments

Known limitations

Building a .vsix

cd vscode-syntax-ext
npm install -g @vscode/vsce
vsce package
# produces turmeric-syntax-X.Y.Z.vsix

See also