AtlatestRepositorysigil-format
sigil-format / treeREADME.md
1
# sigil-format3
Code formatter for [Sigil](https://codeberg.org/sigil/sigil) with4
paren-inference and AST-aware reflow.6
Sigil's formatter reads a source file, tokenizes it, and uses indentation7
as a hint to infer missing or surplus parentheses. Where indentation and8
parens disagree, the indentation wins — the formatter rewrites the parens9
to match. The output is canonically formatted with consistent indentation.11
This package was extracted from the sigil monorepo — the in-tree history12
under `packages/sigil-format/` is preserved here as `master`.14
It backs the `sigil format` CLI subcommand and is used by editor / LSP15
plugins for in-place formatting.17
## Usage19
```scheme20
(import (sigil format))22
;; Format a file on disk23
(format-file "src/example.sgl")24
; => <format-result>26
;; Format a string in memory27
(format-string "(define (foo\n x\n (+ x 1))" "test.sgl")28
; => <format-result>29
```31
The result record exposes the formatted output along with diagnostics:33
```scheme34
(let ((result (format-file "src/example.sgl")))35
(format-result-success result) ; #t/#f36
(format-result-output result) ; formatted source string37
(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 records40
```42
## Modules44
| 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) |49
## Dependencies51
- `sigil-stdlib`52
- `sigil-json` — only used by the `(sigil format json)` submodule for the53
`--format json` CLI output55
## Build & Test57
```bash58
sigil deps install59
sigil build60
sigil test --report61
```63
## License65
BSD-3-Clause