diff options
Diffstat (limited to 'docs/typ/building.typ')
| -rw-r--r-- | docs/typ/building.typ | 81 |
1 files changed, 47 insertions, 34 deletions
diff --git a/docs/typ/building.typ b/docs/typ/building.typ index 8bfcb85b..d4732fa9 100644 --- a/docs/typ/building.typ +++ b/docs/typ/building.typ @@ -60,7 +60,7 @@ must share with its session; `pardes --help` lists every flag. [`-Dplatform`], [`tui`, `gui`, `macos`; absent: the tui and SDL shells together, installed into `~/.local`], [`-Dpdf`], [bool: build the pdf addon, fetching MuPDF the first time; default on once MuPDF is fetched, and off Linux], [`-Djpx`], [bool, `true`: JPEG 2000, and with it scanned PDFs], - [`-Dtree-sitter`], [`disabled`, `zig`, `minimal`, `full`; `full`], + [`-Dgrammars`], [the tree-sitter grammars compiled in: `none` (the runtime alone), `minimal` (C, C++ and Zig) or `full` (all of them; the default)], [`-Dembed-sources`], [bool, `false`: serve the sources under #file("/src")], [`-Dhome-install`], [bool: a bare `zig build` also copies the binaries into `~/.local/bin` and the addon steps theirs into `$XDG_DATA_HOME/pardes/addons`, default true; with `-Dplatform` only `true` copies, and the addons alone], [`-Dstamp-commit`], [bool: the git commit in `--version` and crash records; on for release builds and the `~/.local` install], @@ -92,23 +92,50 @@ moves an anchor fails that file's step. Each table says why, edit by edit. == As a library <library> -A Zig package that depends on pardes is given one module and nothing of -the editor: `pardes-syntax` (`core/lib_syntax.zig`), for a program that -draws source text itself and wants it parsed and coloured as pardes has -it. +As `build.zig`'s head comment says it, word for word: + +A package that depends on pardes is given its syntax, `pardes-syntax` +(`core/lib_syntax.zig`): ``` -// build.zig.zon -.pardes = .{ .path = "../pardes" }, -// build.zig const pardes = b.dependency("pardes", .{ .target = target, .optimize = optimize, - .@"tree-sitter" = .minimal, + .grammars = .minimal, }); exe.root_module.addImport("pardes-syntax", pardes.module("pardes-syntax")); ``` +and, when it asks, the text pane, `pardes-editor` +(`core/lib_editor.zig`), here with a grammar of its own handed in at +run time: + +``` +const pardes = b.dependency("pardes", .{ + .target = target, + .optimize = optimize, + .grammars = .none, + .editor = true, +}); +exe.root_module.addImport("pardes-editor", pardes.module("pardes-editor")); +``` + +`.grammars`: the tree-sitter grammars compiled in: `none` (the runtime +alone), `minimal` (C, C++ and Zig) or `full` (all of them; the default). +`.editor`: exports `pardes-editor` besides `pardes-syntax`, and with it +fetches uucode, mvzr and vaxis. + +Every dependency but tree-sitter's runtime is lazy in the manifest, so +such a package fetches what it asked for and nothing else. +`pardes-editor` has `pardes-syntax` in it as `.syntax`: a file belongs +to one module, so a package imports one of the two. `test/consumer` is +such a package, with both shapes; `lib-test`, which `unit-test` runs, +builds and runs it. + +`build.zig.zon` names pardes by its path: `.pardes = .{ .path = "../pardes" }`. + +=== The syntax + It is the editor's own code under the names it has there. A language is told by a path's extension, as in the editor, and `pathFor` gives a path for a language's name. @@ -122,35 +149,21 @@ for a language's name. [`start`, `stop`], [tree-sitter's allocator, and the end of the parsers kept per language], ) -The `tree-sitter` option is the build's own: `zig`, `minimal` (C, C++ -and Zig) or `full`, the default. Every dependency but tree-sitter's -runtime is lazy in the manifest, so the package fetches the runtime and -its set's grammars and compiles those alone; pardes's own build asks for -what it is missing in one round. Zig still unpacks a lazy package whose -archive its global cache already holds; `--pkg-dir` (or `ZIG_LOCAL_PKG_DIR`) -at pardes's `zig-pkg` shares the one copy. What a pane measures stays -out: a cell's width is vaxis's and uucode's, and a tab is -`config.tab_width` cells wherever it stands. `test/lib` is such a -package, and `zig build lib-test` builds and runs it. +pardes's own build takes `-Dgrammars` too, and asks for what it is +missing in one round. Zig still unpacks a lazy package whose archive its +global cache already holds; `--pkg-dir` (or `ZIG_LOCAL_PKG_DIR`) at +pardes's `zig-pkg` shares the one copy. What a pane measures stays out: a +cell's width is vaxis's and uucode's, and a tab is `config.tab_width` +cells wherever it stands. === The editor `pardes-editor` (`core/lib_editor.zig`) is the text pane as a library: helix's keys on a text kept in memory, no files, commands, builtins, -prompts or views. A package asks for it, and is then given uucode, mvzr -and vaxis's grapheme width besides; one that does not fetches nothing more. -It has `pardes-syntax` in it as `.syntax`: a file belongs to one module, so -a package imports one of the two. - -``` -const pardes = b.dependency("pardes", .{ - .target = target, - .optimize = optimize, - .@"tree-sitter" = .minimal, - .editor = true, -}); -exe.root_module.addImport("pardes-editor", pardes.module("pardes-editor")); -``` +prompts or views. Of vaxis it takes the grapheme width alone. With +`.grammars = .none` it has no grammar of pardes's: a program hands its +own in at run time (`Language`, below), linking the grammar's parser +itself, as `test/consumer` does with C's. The editor is a value of plain data, `Editor(capacity)`: no pointer, no allocator, every capacity in its type, so a program keeps it where it @@ -186,7 +199,7 @@ zig build kitty-harness kitty graphics through a pane end to end (a fake kitt kitten icat and chafa too when installed) zig build syntax-test tree-sitter tests without building the editor zig build syntax deterministic per-byte highlighting snapshots -zig build lib-test the library, from a package that depends on pardes (test/lib); +zig build lib-test the library, from a package that depends on pardes (test/consumer); unit-test runs it too zig build hxlib helix's cases on the library's editor (-- --parity: against the file pane) zig build behaviour-test behaviour through the 9P tree, in process (test/behaviour/), |
