Configuration
Customize CalcMark’s locale, appearance, and formatter defaults.
CalcMark supports user configuration via TOML files. Configuration controls display locale, color mode, theme colors, pane backgrounds, and formatter defaults.
Configuration File Locations #
CalcMark checks for configuration files in this order (later files override earlier ones):
- Embedded defaults (compiled into the binary)
~/.calcmarkrc.toml(dotfile fallback)~/.config/calcmark/config.toml(XDG standard, recommended)
You only need to specify values you want to override – unspecified values use the built-in adaptive palette.
Quick Start #
Create a starter config file with all available options:
cm config --create
This creates ~/.config/calcmark/config.toml with all values commented out and descriptive comments. Uncomment and modify values as needed.
To view your current effective configuration:
cm config
Add your customizations:
[tui]
color_mode = "light" # Use "light" if you have a light terminal background
Display Locale #
The locale setting controls how numbers are formatted in output – specifically the decimal separator and thousands grouping separator.
# ~/.config/calcmark/config.toml
locale = "de-DE"
Supported Locales #
CalcMark accepts any valid BCP 47 locale tag, powered by Go’s golang.org/x/text library. Common examples:
| Locale | Decimal | Thousands | Example: $1500 | Example: 3.14 |
|---|---|---|---|---|
en-US (default) | . | , | $1,500.00 | 3.14 |
de-DE | , | . | $1.500,00 | 3,14 |
fr-FR | , | (non-breaking space) | $1 500,00 | 3,14 |
Other locales like pt-BR, ja-JP, hi-IN, etc. work the same way – CalcMark discovers the correct separators from the locale tag automatically. If a locale string is invalid, CalcMark prints a warning to stderr and falls back to en-US.
Locale affects output formatting only – input syntax always uses . for decimals and , or _ for thousands grouping, regardless of locale.
What Locale Changes #
- Decimal separator in numbers, quantities, and currency values
- Thousands grouping separator in currency mid-range values (e.g.,
$1,500.00) - Decimal within K/M/B suffixes (e.g.,
1.5Min en-US becomes1,5Min de-DE)
What Locale Does Not Change #
- K/M/B/T suffix letters are always English, regardless of locale
- Currency symbol position stays the same (always prefix, e.g.,
$) - Input syntax – CalcMark source code always uses
.for decimals - CalcMark format (
cm convert --to=cm) stays locale-independent for portability - JSON
numeric_valueis always machine-readable ASCII (see JSON Output)
Precedence #
The locale is resolved in this order (first match wins):
--localeCLI flaglocalein config file (config.toml)en-US(default)
CLI Flag Override #
Override the locale for a single invocation:
cm eval --locale=de-DE budget.cm
cm convert doc.cm --to=json --locale=fr-FR
If the locale string is invalid, CalcMark prints a warning to stderr and falls back to en-US.
Color Mode CLI Override #
The --color-mode flag overrides the config file setting for a single invocation:
cm --color-mode=light budget.cm
cm --color-mode=dark budget.cm
Full Configuration Reference #
All supported configuration keys are shown below. Leave color values empty ("") to use the built-in adaptive palette, which automatically provides appropriate colors for your color mode.
# CalcMark Configuration
# Display locale for number formatting (decimal/thousand separators).
# Supported: "en-US", "de-DE", "fr-FR"
locale = "en-US"
[tui]
# Color mode: "light" or "dark"
# Set to "light" if you use a light terminal background.
color_mode = "dark"
[tui.theme]
# Color overrides (hex strings: #RGB or #RRGGBB).
# Leave empty to use the built-in adaptive palette defaults.
# Primary brand color - titles, prompts, variable names
primary = ""
# Accent color - borders, panel highlights
accent = ""
# Error messages
error = ""
# Changed/modified indicator
warning = ""
# Help text, secondary info
muted = ""
# Hints, suggestions, preview text
dimmed = ""
# Calculation results/output
output = ""
# Syntax emphasis in help text
bright = ""
# Divider lines
separator = ""
# Pane backgrounds (leave empty for palette defaults)
source_pane_bg = ""
preview_pane_bg = ""
status_bar_bg = ""
[formatter]
# Default verbosity for output
verbose = false
# Include error details in exports
include_errors = true
# Default output format: "text", "json", "html", "md", "cm"
default_format = "text"
Theme Examples #
Light Terminal Theme #
If you use a light terminal background:
[tui]
color_mode = "light"
[tui.theme]
primary = "#5B21B6"
accent = "#7C3AED"
error = "#DC2626"
warning = "#D97706"
muted = "#6B7280"
dimmed = "#9CA3AF"
output = "#374151"
bright = "#111827"
separator = "#D1D5DB"
High Contrast Theme #
For better visibility:
[tui.theme]
primary = "#FFFF00"
accent = "#00FFFF"
error = "#FF0000"
warning = "#FFA500"
muted = "#FFFFFF"
dimmed = "#CCCCCC"
output = "#FFFFFF"
bright = "#FFFFFF"
separator = "#888888"
Monochrome Theme #
Minimal color palette:
[tui.theme]
primary = "#FFFFFF"
accent = "#AAAAAA"
error = "#FF6666"
warning = "#FFFFFF"
muted = "#888888"
dimmed = "#666666"
output = "#CCCCCC"
bright = "#FFFFFF"
separator = "#444444"
Custom Pane Backgrounds #
Customize the editor pane backgrounds:
[tui.theme]
source_pane_bg = "#1A1A2E"
preview_pane_bg = "#16213E"
status_bar_bg = "#0F3460"
JSON Output and Locale #
When using cm convert --to=json, each result includes a locale-formatted display value and structured type decomposition fields:
| Field | Description | Locale-dependent? | Example (de-DE) |
|---|---|---|---|
value | Locale-formatted display string | Yes | "$1.500,00" |
type | CalcMark type name | No | "currency" |
numeric_value | Machine-readable number (IEEE 754 float64) | No | 1500 |
unit | Unit identifier (ISO 4217 for currency) | No | "USD" |
date_value | ISO 8601 date (Date type only) | No | "2026-03-03" |
is_approximate | True for napkin estimates (Quantity only) | No | true |
Use type for dispatch, numeric_value + unit for computation, and value for display. All fields except value are locale-independent.
{
"source": "price = $1500",
"value": "$1.500,00",
"type": "currency",
"numeric_value": 1500,
"unit": "USD",
"variable": "price"
}
Type Mapping #
| CalcMark Type | type | Has numeric_value | Has unit |
|---|---|---|---|
| Number | "number" | Yes | No |
| Currency | "currency" | Yes | Yes (ISO 4217, e.g., "USD") |
| Quantity | "quantity" | Yes | Yes (e.g., "kg") |
| Rate | "rate" | Yes | Yes (compound, e.g., "MB/s") |
| Duration | "duration" | Yes | Yes (e.g., "hours") |
| Date | "date" | No | No |
| Time | "time" | No | No |
| Boolean | "boolean" | No | No |
What Can’t Be Configured #
The following are part of the internal adaptive palette and are not user-configurable:
- Markdown preview colors (headings, links, code blocks)
- Popup and dialog borders
- Separator shade variations
- Autocomplete highlight colors
These colors derive from the palette and adapt automatically to your color mode.
Troubleshooting #
Config not loading? #
- Run
cm config --checkto validate your config files - Check file permissions:
ls -la ~/.config/calcmark/config.toml - Ensure valid hex colors (must start with
#, e.g.,#RGBor#RRGGBB)
Colors look wrong? #
- Ensure your terminal supports TrueColor (24-bit color)
- Some terminals need TrueColor enabled explicitly (e.g.,
export COLORTERM=truecolor) - Try a simpler theme to isolate the issue
- Use
--color-mode=lightif your terminal has a light background
Deprecation warnings? #
If you see dark_mode is deprecated, replace it in your config:
# Before (deprecated)
dark_mode = true
# After
color_mode = "dark"
Reset to defaults #
Delete or rename your config file:
rm ~/.config/calcmark/config.toml