Calculator Plugin
Help query: "What does the calculator plugin do?" / "How do I use the calculator?" / "How do I evaluate expressions in Volt?"
The calculator plugin (user/calculator.rs) provides an expression evaluator buffer. You write assignments and math expressions in an Input pane, evaluate them, and read results in an Output pane — without leaving the editor.
| Package name | calculator |
| Module | user/calculator.rs |
| Buffer name | *calculator* |
| Buffer kind | calculator |
What it does
- Opens a split buffer with Input (writable) and Output (results) sections
- Parses lines as comments (
# …), assignments (name = expr), or expressions - Evaluates with a recursive-descent math engine (functions + constants)
- Replaces the Output section with results when you evaluate
- Supplies calculator-scoped autocomplete and hover for built-in functions/constants
Open the calculator
| Action | How |
|---|---|
| Command | calculator.open (command palette) |
| Typical leader path | via picker / command palette (F3) |
calculator.openEvaluate and switch panes
| Command | Description | Default chord |
|---|---|---|
calculator.evaluate | Evaluate Input → write results to Output | Ctrl+c Ctrl+c |
calculator.switch-pane | Focus Input ↔ Output | Ctrl+Tab |
Bindings apply in the Workspace scope while the calculator buffer is active. Evaluate emits the host hook plugin.evaluate; the user library handler id is calculator.evaluate-buffer.
Example session
Initial Input content looks like:
# Write expressions below. Press Ctrl+c Ctrl+c to evaluate…
a = 1
b = 2
sqrt(a + b)Press Ctrl+c Ctrl+c. Output shows the evaluated results. Change values, evaluate again.
Language surface
Supported ideas (see user/calculator.rs for the full implementation):
- Arithmetic operators and parentheses
- Assignments reused by later lines
- Functions such as
sqrt, trig, logs,pow, and related helpers - Constants such as
pi,e,tau,inf,nan #line comments
Autocomplete and hover providers are limited to calculator buffers so they do not compete with LSP elsewhere.
Commands reference
| Command | Description |
|---|---|
calculator.open | Open the calculator buffer in the active pane |
calculator.evaluate | Evaluate input and replace the Output section |
calculator.switch-pane | Switch focus between Input and Output |
Related pages
- Builtin plugin catalog
- Create a plugin — calculator is the reference buffer+evaluator pattern
- Autocomplete providers