sorawee / fmt

A code formatter for Racket
Other
72 stars 6 forks source link

Format but do not modify #50

Closed db7 closed 8 months ago

db7 commented 8 months ago

Is it possible to tell fmt to format (indentation, line breaks, etc) but not modify the code? In particular, I’d like fmt to stop changing ( ) into [ ] (in some of my source codes).

sorawee commented 8 months ago

Definitely "yes" for the upcoming fmt2 (though I have not been actively working on it), and "kinda yes" for the current fmt.

In the current version of fmt, you can create .fmt.rkt in the project root with the following content:

#lang racket/base

(provide the-formatter-map)
(require fmt/params)

(current-adjust-paren-shape #f)

(define (the-formatter-map s)
  #f)

Then, when you call raco fmt <path/to/file.rkt> from the project root, paren shapes won't be converted.

(The above method works, but it is very ad-hoc. The goal of fmt2 is to make this kind of configuration adjustment less ad-hoc.)