Open 5outh opened 5 years ago
I think both functionalities are in a way supported already:
-- brittany --exactprint-only
stuff = 42
-- brittany --indent 4
stuff = do
pure 42
otherstuff = do
pure True
The former is based on the assumption that exactprint does its job correctly (the risk of that failing is really really low, in my experience). But both for making things more intuitive and prevent wasting cpu-cycles on calculating a complex hopefully-identity, we probably indeed want "brittany-disable-module" that produces input directly (and does nothing on --write-mode=inplace
).
@lspitzner is there an FAQ that could be updated to include this information?
It seems like maybe the original issue is solved? But the inline config definitely should be documented. It's in the change log for 0.11 and in #136, but that's it.
Can anyone quickly say what the configuration looks like for this? I've tried every variant of -- brittany disable-formatting
I can think of, but none of them seem to cause the file where this comment appears to be ignored.
I think you can use -- brittany --exactprint-only
, although it still seems to format the module header.
/tmp> cat gh197.hs
-- brittany --exactprint-only
module Main ( main ) where
main
=
putStrLn
ugly
ugly
= 'u'
: 'g'
: 'l'
: 'y'
: []
/tmp> brittany gh197.hs
-- brittany --exactprint-only
module Main
( main
)
where
main
=
putStrLn
ugly
ugly
= 'u'
: 'g'
: 'l'
: 'y'
: []
My hope was actually to have a way to avoid https://github.com/lspitzner/brittany/issues/242 so this isn't quite enough; I'd just like the whole file to be completely ignored. I guess the only way to do this is just to make sure that brittany never looks at the file in the first place?
As far as I know, yeah that's the only way.
We currently have directives for disabling/modifying specific bindings (
-- brittany-disable-next-binding
/-- brittany-next-binding --columns=100
, e.g.). Certain files either choke on brittany, or are written in a particular style and should be ignored by the process. In those cases, I'd love if there were a directive akin to:-- brittany-disable
which ignores the entire module; and similarly
-- brittany-modify
or something that that effect for modifying brittany settings for all top-level bindings in a module.This might seem weird since
brittany
works on a per-module basis, but this would be really nice when working with editor integrations and full-project formatting scripts, for example.