Editor Setup¶
Graphcal provides editor extensions with rich language support through the built-in LSP server. A key feature is inlay hints that display computed values inline, turning your editor into a live calculation sheet.
LSP Features¶
The Graphcal LSP server (graphcal lsp) provides:
| Feature | Description |
|---|---|
| Diagnostics | Real-time error reporting: parse errors, dimension mismatches, unknown references, and visibility violations |
| Completion | Context-aware keywords, references, types, dimensions, indexes, units, imports, built-ins, and constructors |
| Signature help | Built-in and imported plugin function signatures with active positional parameters |
| Hover | Type, dimension, unit, signature, and documentation information |
| Go to definition | Jump from a reference to its local or imported declaration |
| Find references | Locate canonical usages across the active loaded project |
| Rename | Safely rename symbols when the active loaded project proves complete coverage |
| Document symbols | Outline declarations in the current file |
| Inlay hints | Display computed values or type fallbacks for param, node, and const declarations |
| Code actions | Quick fixes for supported diagnostics, including visibility, exact exponents, and imports |
| Document links | Clickable links for loader-resolved import and include paths |
| Formatting | Format the current document (same as graphcal format) |
Inlay hints: live calculation view
The inlay hints feature is what makes Graphcal feel like a live spreadsheet. As you edit your .gcl file, the LSP evaluates the computation graph and shows the resulting values next to eligible param, node, and const declarations, with a type fallback when no value is available. Change an input and watch all dependent values update.
Rename is limited to symbols whose affected uses are all known within the loaded project. It may be unavailable for exported symbols used by unopened files, or when a new name would create ambiguous references.
VS Code¶
The VS Code extension provides syntax highlighting (via TextMate grammar) and full LSP support.
Installation¶
Install the published Graphcal extension from the Visual Studio Marketplace.
You can also install it from VS Code:
- Open the Extensions view.
- Search for Graphcal.
- Install the extension published by Graphcal.
Configuration¶
| Setting | Default | Description |
|---|---|---|
graphcal.lsp.enabled |
true |
Enable/disable the LSP server |
graphcal.lsp.path |
"graphcal" |
Path to the graphcal binary |
If graphcal is not on your PATH, set graphcal.lsp.path to the full path of the binary.
Zed¶
The Zed extension provides syntax highlighting (via tree-sitter grammar) and LSP support.
Setup¶
The Zed extension is not yet published. Install it as a dev extension for now:
- Clone the extension repository:
https://github.com/graphcal-lang/zed-graphcal - Open the command palette in Zed
- Select "Extensions: Install Dev Extension"
- Navigate to the cloned
zed-graphcaldirectory - The extension will be installed and activated
Helix¶
Helix can use the Graphcal tree-sitter grammar and the built-in LSP server.
Add the following to ~/.config/helix/languages.toml:
[[grammar]]
name = "graphcal"
source = { git = "https://github.com/graphcal-lang/tree-sitter-graphcal", rev = "main" }
[language-server.graphcal-lsp]
command = "graphcal"
args = ["lsp"]
[[language]]
name = "graphcal"
scope = "source.graphcal"
file-types = ["gcl"]
roots = ["graphcal.toml"]
comment-token = "//"
language-servers = ["graphcal-lsp"]
indent = { tab-width = 2, unit = " " }
auto-format = true
Then fetch and build the grammar:
graphcal must be available on your PATH; otherwise, set command to the full path of the Graphcal binary.
Helix syntax highlighting queries¶
The commands above install/update the parser binary, but Helix does not automatically install or refresh highlight query files from custom grammar repositories. Graphcal highlighting is loaded separately from:
Install the highlight query after fetching the grammar:
mkdir -p ~/.config/helix/runtime/queries/graphcal
cp ~/.config/helix/runtime/grammars/sources/graphcal/queries/highlights.scm \
~/.config/helix/runtime/queries/graphcal/highlights.scm
If you prefer not to rely on Helix's grammar source cache, download the query directly instead:
mkdir -p ~/.config/helix/runtime/queries/graphcal
curl -fsSL \
https://raw.githubusercontent.com/graphcal-lang/tree-sitter-graphcal/main/queries/highlights.scm \
-o ~/.config/helix/runtime/queries/graphcal/highlights.scm
Neovim¶
For Neovim with nvim-treesitter:
- Add
https://github.com/graphcal-lang/tree-sitter-graphcalas the grammar source in your tree-sitter config - Copy the highlight queries from the repository's
queries/highlights.scm
For LSP support, configure Neovim to run graphcal lsp over stdin/stdout for .gcl files.
Example configuration with nvim-lspconfig:
vim.api.nvim_create_autocmd("FileType", {
pattern = "graphcal",
callback = function()
vim.lsp.start({
name = "graphcal",
cmd = { "graphcal", "lsp" },
})
end,
})
Other editors¶
For any editor with tree-sitter and LSP support, install the grammar from graphcal-lang/tree-sitter-graphcal and configure the language server to run graphcal lsp for .gcl files.