Skip to content

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 namecalculator
Moduleuser/calculator.rs
Buffer name*calculator*
Buffer kindcalculator

What it does ​

  1. Opens a split buffer with Input (writable) and Output (results) sections
  2. Parses lines as comments (# …), assignments (name = expr), or expressions
  3. Evaluates with a recursive-descent math engine (functions + constants)
  4. Replaces the Output section with results when you evaluate
  5. Supplies calculator-scoped autocomplete and hover for built-in functions/constants

Open the calculator ​

ActionHow
Commandcalculator.open (command palette)
Typical leader pathvia picker / command palette (F3)
text
calculator.open

Evaluate and switch panes ​

CommandDescriptionDefault chord
calculator.evaluateEvaluate Input → write results to OutputCtrl+c Ctrl+c
calculator.switch-paneFocus Input ↔ OutputCtrl+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:

text
# 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 ​

CommandDescription
calculator.openOpen the calculator buffer in the active pane
calculator.evaluateEvaluate input and replace the Output section
calculator.switch-paneSwitch focus between Input and Output

Volt — modal editor platform · docs optimized for in-editor help search