[ANN] Piecetab — Lua-friendly building blocks for text editors

28 views
Skip to first unread message

Xavier Wang

unread,
Aug 22, 2026, 6:48:16 AM (2 days ago) Aug 22
to lu...@googlegroups.com
Hi all,

I'd like to announce Piecetab: a set of libraries for building text
editors, designed to be used from Lua.

The repo ships Lua bindings and declaration files for all core C
components, plus an editor.lua demo showing how to assemble a working
modal editor in Lua.

In particular, the piecetab Lua binding bundles piecetab / linecache /
undotree into a single file-like document interface: it supports both
byte and line positions with bidirectional lookup, and each commit
automatically creates an undo-tree node — so you can jump back to any
previous editing state.

To running the Lua demo, using `just lua/deps` to build bindings, then
run demo with `lua editor.lua [file]`. To enable syntax highlighting,
you should have libtree-sitter installed, and using `just lua/ts` to
build and install grammars, then the syntax highlighting will be
enabled automatically.

There is also a pure Lua module `lsp.lua` implements the basic lsp
client. Other Lua bindings include:

spantree — span/attribute coloring for highlighting and diagnostics
cellgrid — screen buffer with efficient redraw diff
termfeed — terminal input, a modern rewrite of libtermkey (CSI/SS3,
UTF-8, alt keys, mouse, OSC52)
json — vendored yyjson binding
treesitter — binding over libtree-sitter for incremental syntax highlighting

All C bindings also include .d.lua declaration files, so Lua Language
Server (luals) can provide type checking and autocompletion.

On the C side, the libraries are stb-style single-header C89 —
lightweight, self-contained, and easy to embed. All stb-style headers
are 100% line covered, and 95+% branch covered.

Repository: https://github.com/starwing/piecetab
License: MIT

I'd appreciate any feedback, especially from people interested in
editors, terminal UIs, or Lua/C integration.

Thanks!

--
regards,
Xavier Wang.
Reply all
Reply to author
Forward
0 new messages