Commit7aa9283eRecorded25 Apr 2026Repositorysigil-format

Extract sigil-format from sigil monorepo

Message

Sigil's code formatter (paren-inference + AST-aware reflow), now its own repo. History under packages/sigil-format/ in the monorepo is preserved here as master via git filter-repo.

Scaffolding: - README with usage, module table (sigil format + sigil format json), build/test commands. - .gitignore for build/ + .sigil/. - manifest.scm minimal Scheme guix-shell environment. - dev-redirects.sgl wires from-git deps to local sibling checkouts (../sigil for sigil-stdlib via monorepo, ../sigil-json). - sigil.lock from sigil deps install (2 entries).

package.sgl: - Added version 0.13.1. - Fixed description to accurately describe the code formatter (was copy-paste "String formatting utilities" — wrong). - url -> codeberg:sigil/sigil-format. - sigil-stdlib swapped from-workspace -> from-git monorepo-resident ^0.13.1; sigil-json stays at ^0.13.1 (already external).

sigil build clean. sigil test --report 19/19 passed.

Per procedures/sigil-package-extraction.

Changed
 .gitignore        |  2 ++
 README.md         | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 dev-redirects.sgl |  9 +++++++++
 manifest.scm      |  7 +++++++
 package.sgl       | 12 +++++++-----
 sigil.lock        | 13 +++++++++++++
 6 files changed, 103 insertions(+), 5 deletions(-)
Diff
.gitignoreadded
@@ -0,0 +1,2 @@
+1
build/
+2
.sigil/
README.mdadded
@@ -0,0 +1,65 @@
+1
# sigil-format
+2
+3
Code formatter for [Sigil](https://codeberg.org/sigil/sigil) with
+4
paren-inference and AST-aware reflow.
+5
+6
Sigil's formatter reads a source file, tokenizes it, and uses indentation
+7
as a hint to infer missing or surplus parentheses. Where indentation and
+8
parens disagree, the indentation wins — the formatter rewrites the parens
+9
to match. The output is canonically formatted with consistent indentation.
+10
+11
This package was extracted from the sigil monorepo — the in-tree history
+12
under `packages/sigil-format/` is preserved here as `master`.
+13
+14
It backs the `sigil format` CLI subcommand and is used by editor / LSP
+15
plugins for in-place formatting.
+16
+17
## Usage
+18
+19
```scheme
+20
(import (sigil format))
+21
+22
;; Format a file on disk
+23
(format-file "src/example.sgl")
+24
; => <format-result>
+25
+26
;; Format a string in memory
+27
(format-string "(define (foo\n x\n (+ x 1))" "test.sgl")
+28
; => <format-result>
+29
```
+30
+31
The result record exposes the formatted output along with diagnostics:
+32
+33
```scheme
+34
(let ((result (format-file "src/example.sgl")))
+35
(format-result-success result) ; #t/#f
+36
(format-result-output result) ; formatted source string
+37
(format-result-errors result) ; list of <format-error>
+38
(format-result-warnings result) ; list of <format-warning>
+39
(format-result-inferences result)) ; list of inferred-paren records
+40
```
+41
+42
## Modules
+43
+44
| Module | Purpose |
+45
|--------|---------|
+46
| `(sigil format)` | Core formatter — `format-file`, `format-string`, result + diagnostic records |
+47
| `(sigil format json)` | JSON output of format results, used by `sigil format --format json` (lazy-loaded post-bootstrap) |
+48
+49
## Dependencies
+50
+51
- `sigil-stdlib`
+52
- `sigil-json` — only used by the `(sigil format json)` submodule for the
+53
`--format json` CLI output
+54
+55
## Build & Test
+56
+57
```bash
+58
sigil deps install
+59
sigil build
+60
sigil test --report
+61
```
+62
+63
## License
+64
+65
BSD-3-Clause
dev-redirects.sgladded
@@ -0,0 +1,9 @@
+1
;; Development redirects — point dependencies at local Sigil checkouts
+2
(redirects
+3
repos: (list
+4
(for-repo
+5
url: "codeberg:sigil/sigil"
+6
use: (from-path dir: "../sigil"))
+7
(for-repo
+8
url: "codeberg:sigil/sigil-json"
+9
use: (from-path dir: "../sigil-json"))))
manifest.scmadded
@@ -0,0 +1,7 @@
+1
;; sigil-format Development Environment
+2
;; Use with: guix shell -m manifest.scm
+3
+4
(specifications->manifest
+5
'("gcc-toolchain"
+6
"make"
+7
"pkg-config"))
package.sglmodified
@@ -1,14 +1,16 @@
1
;;; sigil-format - String formatting utilities
+1
;;; sigil-format - Sigil code formatter
2
;;;
3
;;; Provides string formatting facilities for Sigil.
+3
;;; Code formatter for Sigil with paren-inference and AST-aware reflow.
+4
;;; Backs the `sigil format` CLI subcommand and editor/LSP plugins.
5
6
(package
7
name: "sigil-format"
7
description: "String formatting utilities for Sigil"
8
url: "https://codeberg.org/sigil/sigil"
+8
version: "0.13.1"
+9
description: "Sigil code formatter (paren-inference + AST-aware reflow)"
+10
url: "https://codeberg.org/sigil/sigil-format"
11
license: "BSD-3-Clause"
12
authors: (list "David Wilson <[email protected]>")
13
14
dependencies: (list
13
(from-workspace name: "sigil-stdlib")
+15
(from-git url: "codeberg:sigil/sigil" package: "sigil-stdlib" version: "^0.13.1")
16
(from-git url: "codeberg:sigil/sigil-json" version: "^0.13.1")))
sigil.lockadded
@@ -0,0 +1,13 @@
+1
;; Auto-generated by sigil deps install. Do not edit.
+2
(lock
+3
(package name: "sigil-stdlib"
+4
url: "codeberg:sigil/sigil"
+5
ref: "^0.13.1"
+6
sha: "1aea1cecd3487bf07d071da2c1e7eb3cf4bbdb21"
+7
package-selector: "sigil-stdlib")
+8
(package name: "sigil-json"
+9
url: "codeberg:sigil/sigil-json"
+10
ref: "^0.13.1"
+11
sha: "811b63925399a663e4b7dd25fb0813d59d33f557"
+12
version: "0.13.1")
+13
)