Skip to content

Commit 080a7f1

Browse files
committed
feat: ~/.config/writ/config.toml for theme (presets/custom/overrides) and font (family+size), threaded into the app
1 parent 3da688f commit 080a7f1

6 files changed

Lines changed: 563 additions & 19 deletions

File tree

Cargo.lock

Lines changed: 169 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ math = ["dep:ratex-parser", "dep:ratex-layout", "dep:ratex-render", "dep:ratex-t
4848
editor = ["git", "github", "watch"]
4949

5050
# the desktop editor application (winit shell). implies editor.
51-
app = ["editor", "remote-images", "mermaid", "math", "dep:winit", "dep:arboard", "dep:open", "dep:clap"]
51+
app = ["editor", "remote-images", "mermaid", "math", "dep:winit", "dep:arboard", "dep:open", "dep:clap", "dep:toml", "dep:dirs"]
5252

5353
# the GhostText daemon (writd binary)
5454
ghosttext = ["app", "dep:tokio-tungstenite", "dep:futures"]
@@ -88,6 +88,8 @@ rustls = { version = "0.23.36", features = ["ring"], optional = true }
8888
unicode-segmentation = "1.13"
8989
serde = { version = "1", features = ["derive"] }
9090
serde_json = { version = "1", optional = true }
91+
toml = { version = "0.8", optional = true }
92+
dirs = { version = "5", optional = true }
9193
tokio = { version = "1", features = ["full"], optional = true }
9294
tokio-tungstenite = { version = "0.29", optional = true }
9395
tree-sitter = "0.26"

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,30 @@ Flags:
2929
| `--autosave` | Save on every edit (used by the GhostText daemon) |
3030
| `--github-repo <owner/repo>` | GitHub context for ref validation (else auto-detected from the git remote) |
3131
| `--github-token <token>` | GitHub API token (or the `GITHUB_TOKEN` env var) for ref validation, hover cards, and autocomplete |
32+
| `--config <path>` | Config file location (default `~/.config/writ/config.toml`) |
3233

3334
writ is rendered on [winit](https://github.com/rust-windowing/winit) + [wgpu](https://wgpu.rs) + [Vello](https://github.com/linebender/vello) + [Parley](https://github.com/linebender/parley) (GPU 2D rendering and text layout). On Linux/Mesa (including Asahi) select the Vulkan backend with `WGPU_BACKEND=vulkan`. Fonts are resolved via [Fontique](https://github.com/linebender/parley) with fontconfig loaded at runtime — no `-dev` headers needed.
3435

36+
### Configuration
37+
38+
writ reads an optional TOML config from `~/.config/writ/config.toml` (platform config dir, overridable with `--config <path>`). It sets the theme and the document font; a missing or malformed file just falls back to the built-in defaults. See [`config.example.toml`](config.example.toml) for a fully commented example.
39+
40+
```toml
41+
[font]
42+
family = "JetBrains Mono" # must be monospace; verified at startup, falls back if not
43+
size = 18.0
44+
45+
[theme]
46+
name = "nord" # built-in: dracula (default), nord, solarized-light — or a [themes.*] you define
47+
48+
[theme.overrides] # optional per-color hex tweaks on top of the selected theme
49+
comment = "#7A88B8"
50+
```
51+
52+
- **Themes.** Pick a built-in preset by `name`, or define your own under `[themes.<name>]` (any omitted color is inherited from dracula) and select it. `[theme.overrides]` applies hex tweaks on top. The 12 color slots are `background`, `surface`, `foreground`, `selection`, `comment`, `red`, `orange`, `yellow`, `green`, `cyan`, `purple`, `pink`.
53+
- **Font.** The family **must be monospace** — writ verifies fixed-pitch at startup and falls back to the system monospace (with a warning) if the font is proportional or not installed, protecting its deterministic wrapping.
54+
- Config is read once at startup; edits take effect on the next launch.
55+
3556
### Inline git diff
3657

3758
When the open file lives in a git repository, writ renders a live inline diff against `HEAD`: added lines and words are tinted green, deleted lines appear as red "ghost" rows above their position, all with the same markdown rendering as the rest of the document. writ watches the file, so edits made by an external tool (e.g. an AI agent) reload and re-diff live.

0 commit comments

Comments
 (0)