A customizable code formatter for the C3 language, written in C3.
Check the c3fmt-vscode extension to use it inside VS Code.
Usage:
c3fmt [<options>] <files>Options:
-h, --help - Show this help.
-v, --version - Show current version.
--in-place - Format files in place.
--stdin - Read input from stdin.
--stdout - Output result to stdout.
--config=<path> - Specify a config file.
--default - Force default config.
c3fmt will try to find a .c3fmt format inside the working directory. You can also
pass your own path to c3fmt, or force the default configuration.
You can look at .c3fmt for the default configuration.
Run c3c build to build c3fmt.
The only dependency is the tree-sitter sdk.
- Code wrapping (current breaks with nested constructions).
- Align consecutive assignments / declaration / comments.
- Wrapping indent option. (ContinuationIndentWidth)
- Align wrapped items.
- Space before <...> options.
- Import sorting
- Pointer alignment ? (kind of a pain and I think right alignment is heretic)
There are two tests for the moment :
- Corpus takes a
.c3source file, format it and compare it the same file with a_f.c3format corresponding to the expected output. - Stdlib formats every file from the C3 standard library, then verifiy it still compiles with the same semantic. (For the moment it won't automatically try to compile it, but you can go to
test/stdliband runc3c build)
Each test checks that the syntax tree of the formatted code is the same as the original one.
