AtlatestRepositorysigil-format
1# sigil-format
2
3Code formatter for [Sigil](https://codeberg.org/sigil/sigil) with
4paren-inference and AST-aware reflow.
5
6Sigil's formatter reads a source file, tokenizes it, and uses indentation
7as a hint to infer missing or surplus parentheses. Where indentation and
8parens disagree, the indentation wins — the formatter rewrites the parens
9to match. The output is canonically formatted with consistent indentation.
11This package was extracted from the sigil monorepo — the in-tree history
12under `packages/sigil-format/` is preserved here as `master`.
14It backs the `sigil format` CLI subcommand and is used by editor / LSP
15plugins for in-place formatting.
17## Usage
19```scheme
20(import (sigil format))
22;; Format a file on disk
23(format-file "src/example.sgl")
24; => <format-result>
26;; Format a string in memory
27(format-string "(define (foo\n x\n (+ x 1))" "test.sgl")
28; => <format-result>
29```
31The result record exposes the formatted output along with diagnostics:
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```
42## Modules
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) |
49## Dependencies
51- `sigil-stdlib`
52- `sigil-json` — only used by the `(sigil format json)` submodule for the
53 `--format json` CLI output
55## Build & Test
57```bash
58sigil deps install
59sigil build
60sigil test --report
61```
63## License
65BSD-3-Clause