A Racket formatter that add/remove some whitespaces but respects newline.
It should work as expected, except some rules for macros and special forms are missing.
before
#lang racket
(define(fib n )
(if (<= n 1)
1
(+ (fib (- n 1))
(fib (- n 2)) )))
after
#lang racket
(define (fib n)
(if (<= n 1)
1
(+ (fib (- n 1))
(fib (- n 2)))))
- format a 5k lines file in 100ms on a 6 years old laptop
The biggest Racket file class-internal.rkt in racket/racket repo has almost 5k lines, so I think it's fast enough.
- fix indent
- respect newline
- works for unbalanced code
- remove trailing spaces
- force only one space between two tokens with several exceptions
- force only one empty line at the end of the file
- make it configurable
- raco integration
- read scmindent compatible configuration file
- skip code that surrounded by special comments
- support range formatting
- a configurable system looks like macro but allows user customize the formatting
- support sort
require
- support keyword arguments and default arguments
- support sort
- refactor
- isolate the lexer workarounds and special escape comments processing
- simplify the core logic
# install
raco pkg install fixw
# show help
raco fixw -h
# read from stdin and output formatted text to stdout
raco fixw
# format current directory recursively
raco fixw .
See online docs.