README.md

July 24, 2026 · View on GitHub

████████╗ ██████╗  ██████╗
╚══██╔══╝██╔═══██╗██╔════╝
   ██║   ██║   ██║██║
   ██║   ██║   ██║██║
   ██║   ╚██████╔╝╚██████╗
   ╚═╝    ╚═════╝  ╚═════╝

License: MIT zmax plugin

[MARKDOWN TABLE OF CONTENTS — COMPILED]

"toc — one word, and the headings become a table of contents."

[NATIVE ZMAX PLUGIN]

:toc scans the current buffer's Markdown ATX headings and inserts a nested table of contents at the cursor — as a native zmax plugin: a compiled Rust cdylib loaded at runtime over zmax's stable C ABI, no editor recompile. Zero dependencies.

zmax · zmax-native · docs


Table of Contents


[0x00] OVERVIEW

:toc     → - [Overview](#overview)
           - [Install](#install)
             - [From source](#from-source)
           - [Usage](#usage)

[0x01] INSTALL

:zmax-native add MenkeTechnologies/zmax-native-toc

zmax-native, zmax's package manager, clones the repo, runs cargo build --release, installs the cdylib into the content-addressed store under ~/.zmax/pkg/ (SHA-256 pinned), and dlopens it — by mmap, so the loader pages the library in. To self-install on first launch and load zero-network after, add one line to ~/.zmax/init.vim (the leading : is required):

:zmax-native get MenkeTechnologies/zmax-native-toc

Manual build

cargo build --release

Then, in zmax:

:zmax-native load ./target/release/libzmax_native_toc.dylib   # .so on Linux

[0x02] USAGE

Put the cursor where the TOC should go and run :toc. It scans ATX headings (#######), skips fenced code blocks, and inserts a nested list. Anchors follow GitHub's slug rules (lowercase, spaces to -, punctuation dropped); nesting is relative to the shallowest heading found.


[0x03] HOW IT WORKS

The plugin registers one typable command, toc, through the zmax-native SDK. It reads the whole buffer with the host buffer_text callback, walks it line by line — toggling a fenced-code flag on ```/~~~ so # inside code is ignored — parses each #{1,6} heading into a level and title, computes the shallowest level for relative indentation, builds - [title](#anchor) lines, and inserts them with the host insert_text callback. No dependencies.


[0xFF] LICENSE

MIT. Built against the zmax-native plugin SDK. See LICENSE.