Spar Language Support
VS Code extension for the Spar configuration language.
Spar is a statically typed configuration language that compiles to JSON. This extension adds syntax highlighting, real-time error reporting, hover documentation, intelligent completions, and formatting for .spar files.
Features
Syntax highlighting
Full TextMate grammar for all Spar constructs — variables, sections, types, operators, string interpolation, comments, imports, and schema declarations.
Real-time diagnostics
Errors are reported as you type, sourced from the full Spar compiler pipeline: lex, parse, name resolution, and type checking.
Cannot find name `Datbase` — did you mean `Database`? [resolve]
Type mismatch: expected `int`, found `str` [type]
Missing required schema field `port` [schema]
Hover documentation
Hover over any symbol to see its type and resolved value.
- Variable hover: type and value
- Section hover: path and field summary
- Import alias hover: the exported symbols available from that file
- Field hover: declared type
Completions
Context-aware completions trigger on ::. Inside a section body, field names from the current section and visible symbols are suggested. Inside an import path, exported names from the imported file appear.
Use Format Document (Shift+Alt+F / ⇧⌥F) to format the open .spar file using the same engine as spar fmt. The formatter normalises spacing, indentation, and section layout.
Commands
Open the Command Palette (Ctrl+Shift+P / ⌘⇧P) and search for:
| Command |
Description |
Spar: Check File |
Run spar check on the active file and show results in the output panel |
Spar: Emit JSON |
Run spar emit on the active file and open the JSON output in a new editor tab |
Requirements
The extension requires two binaries on your PATH:
| Binary |
Purpose |
Install |
spar |
CLI — used by the Check File and Emit JSON commands |
Build from source |
spar-ls |
Language server — powers diagnostics, hover, completions, formatting |
Build from source |
Both are Rust binaries installed from source:
# Install spar
git clone https://github.com/oraclevs/spar.git
cd spar && cargo build --release
sudo cp target/release/spar /usr/local/bin/
# Install spar-ls
git clone https://github.com/oraclevs/spar-ls.git
cd spar-ls && cargo build --release
sudo cp target/release/spar-ls /usr/local/bin/
Installation
The extension is distributed as a .vsix file. Download the latest release from the releases page and install it:
code --install-extension vscode-spar-0.1.0.vsix
Or install from inside VS Code: Extensions → ... menu → Install from VSIX…
Configuration
| Setting |
Default |
Description |
spar.serverPath |
"spar-ls" |
Path to the spar-ls binary. Use "spar-ls" to resolve from PATH, or set an absolute path if it is installed elsewhere. |
Troubleshooting
No diagnostics / hover not working
The extension requires spar-ls to be on your PATH (or configured via spar.serverPath). Open the VS Code Output panel, select Spar Language Server from the dropdown, and check for startup errors.
"spar-ls" not found
Build and install spar-ls from source — see Requirements above. After installing, restart VS Code.
Format Document does nothing
Ensure spar-ls is running (check the Output panel). The formatter is provided by the language server, not the extension itself.
- spar — compiler, CLI, and full language documentation
- spar-ls — LSP server, editor setup for Neovim and Helix
- tree-sitter-spar — Tree-sitter grammar
License
MIT — see LICENSE.