···5566Let your code breathe!
7788-Iku is a grammar-based Go formatter that enforces consistent blank-line placement by AST node type.
88+Iku is a grammar-based Go formatter that enforces consistent blank-line placement by statement and declaration type.
991010## Philosophy
1111···13131414## Rules
15151616-1. **Same AST type means no blank line**: Consecutive statements of the same type stay together
1717-2. **Different AST type means blank line**: Transitions between statement types get visual separation
1818-3. **Scoped statements get blank lines**: `if`, `for`, `switch`, `select` always have blank lines before them
1919-4. **Top-level declarations are separated**: Functions, types, and variables at the package level get blank lines between them
1616+1. **Same type means no blank line**: Consecutive statements of the same type stay together
1717+2. **Different type means blank line**: Transitions between statement types get visual separation
1818+3. **Scoped constructs get blank lines**: `if`, `for`, `switch`, `select`, `func`, `type struct`, `type interface` always have blank lines around them
1919+4. **Declarations use token types**: `var`, `const`, `type`, `func`, `import` are distinguished by their keyword, not grouped as generic declarations
20202121## How It Works
2222···134134type Config struct {
135135 Name string
136136}
137137+type ID int
138138+type Name string
137139var defaultConfig = Config{}
140140+var x = 1
138141func main() {
139142 run()
140143}
···149152 Name string
150153}
151154155155+type ID int
156156+type Name string
157157+152158var defaultConfig = Config{}
159159+var x = 1
153160154161func main() {
155162 run()
···159166 process()
160167}
161168```
169169+170170+Notice how:
171171+- `type Config struct` is scoped (has braces), so it gets a blank line
172172+- `type ID int` and `type Name string` are unscoped type aliases, so they group together
173173+- `var defaultConfig` and `var x` are unscoped, so they group together
174174+- `func main()` and `func run()` are scoped, so each gets a blank line
162175163176### Switch Statements
164177