Showcase: Margin, a local-first markdown notes app for macOS built on CM6

I’ve been building Margin (https://gomargin.app), a markdown notes app for Mac (Tauri v2, so CM6 runs in the system webview). Notes are plain markdown files on disk; the editor is where I’ve spent most of my time, and it’s all CodeMirror 6.

The CM6-specific bits that might interest people here:

Live preview is one ViewPlugin building decorations off the Lezer syntax tree: markdown syntax hides away from the cursor, and widgets render callouts, tables, attachments, emoji shortcodes, dates, and wiki-style page links in place. Tables get their own widget with a nested cell editor. On top of that there’s custom autocompletion, folding, auto-pairing, list indent handling, and line drag-to-move.

Files can change under the editor (vim, git, an agent writing to the folder). A Rust watcher (notify crate) debounces events, filters out the app’s own writes, and tells the frontend to reload from disk. Dirty in-memory buffers win over the disk copy, and the open editor only takes the new doc when it’s not focused (single full-doc dispatch), so an external edit never clobbers what you’re mid-typing.

Themes aren’t EditorView.theme: each of the 29 themes is a pair of dark/light CSS-variable maps applied with setProperty, and the CM styles just read the variables. Made supporting community color schemes (Nord, Catppuccin, Gruvbox, Rosé Pine and so on) mostly a data problem.

Happy to go deeper on any of it. The app itself is pre-launch (waitlist on the site) but the editor work is the part I wanted to share here.