···11# ๐ Iku
2233-> Grammar-Aware Go Formatter: Structure through separation
33+> Grammar-Aware Code Formatter: Structure through separation
445566Let your code breathe!
7788-Iku is a grammar-based Go formatter that enforces consistent blank-line placement by statement and declaration type.
88+Iku is a grammar-based formatter that enforces consistent blank-line placement by statement and declaration type. It supports Go, JavaScript, TypeScript, JSX, and TSX.
991010## Philosophy
1111···20202121## How It Works
22222323-Iku applies standard Go formatting (via [go/format](https://pkg.go.dev/go/format)) first ([formatter.go#29](https://github.com/Fuwn/iku/blob/main/formatter.go#L29)), then adds its grammar-based blank-line rules on top. Your code gets `go fmt` output plus structural separation.
2323+For Go files, Iku applies standard Go formatting (via [go/format](https://pkg.go.dev/go/format)) first, then adds its grammar-based blank-line rules on top. Your code gets `go fmt` output plus structural separation.
2424+2525+For JavaScript and TypeScript files (`.js`, `.ts`, `.jsx`, `.tsx`), Iku uses a heuristic line-based analyser that classifies statements by keyword (`function`, `class`, `if`, `for`, `try`, etc.) and applies the same blank-line rules.
24262527## Installation
2628···42444345# Format and print to stdout
4446iku file.go
4747+iku component.tsx
45484649# Format in-place
4750iku -w file.go
5151+iku -w src/
48524949-# Format entire directory
5353+# Format entire directory (Go, JS, TS, JSX, TSX)
5054iku -w .
51555256# List files that need formatting
···6367| `-w` | Write result to file instead of stdout |
6468| `-l` | List files whose formatting differs |
6569| `-d` | Display diffs instead of rewriting |
6666-| `--comments` | Comment attachment mode: `follow`, `precede`, `standalone` |
6770| `--version` | Print version |
7171+7272+## Configuration
7373+7474+Iku looks for `.iku.json` or `iku.json` in the current working directory.
7575+7676+```json
7777+{
7878+ "comment_mode": "follow",
7979+ "group_single_line_functions": false
8080+}
8181+```
8282+8383+All fields are optional. Omitted fields use their defaults.
8484+8585+### `comment_mode`
8686+8787+Controls how comments interact with blank-line insertion. Default: `"follow"`.
8888+8989+| Mode | Behaviour |
9090+|------|-----------|
9191+| `follow` | Comments attach to the **next** statement. The blank line goes **before** the comment. |
9292+| `precede` | Comments attach to the **previous** statement. The blank line goes **after** the comment. |
9393+| `standalone` | Comments are independent. Blank lines are placed strictly by statement rules. |
9494+9595+### `group_single_line_functions`
9696+9797+When `true`, consecutive single-line function declarations of the same type are kept together without blank lines. Default: `false`.
9898+9999+```go
100100+// group_single_line_functions = true
101101+func Base() string { return baseDirectory }
102102+func Config() string { return configFile }
103103+104104+// group_single_line_functions = false (default)
105105+func Base() string { return baseDirectory }
106106+107107+func Config() string { return configFile }
108108+```
6810969110## Examples
70111