1
1
mirror of https://github.com/google/ormolu.git synced 2024-08-15 19:10:29 +03:00
Commit Graph

259 Commits

Author SHA1 Message Date
Javran Cheng
d186cdf5ba
Fix a weird formatting on RecordDotSyntax support. (#3) 2021-02-17 14:24:05 -08:00
Jinwoo Lee
24fd712462 Fix failing tests by updating golden files.
The formatting result for dot-multiline-out.hs looks weird and we
should fix it. But checking this in so that tests pass.
2021-02-16 21:09:34 -08:00
Mark Karpov
90916d77ff Fix the newly introduced idempotence issue with parens 2021-02-16 20:31:24 -08:00
Mark Karpov
dee64118bf Simplify rendering of parentheses in arithmetic expressions 2021-02-16 20:30:01 -08:00
Mark Karpov
90dc7bf34d Change rendering of type signatures 2021-02-16 20:24:22 -08:00
Mark Karpov
4cb97b0561 Switch to leading commas in tuples and lists 2021-02-16 20:24:22 -08:00
amesgen
34bdf62429
Group StandaloneKindSignatures with type synonyms 2021-02-02 21:15:27 +01:00
Mark Karpov
93bef509ca Display diffs in the checking mode
Also improve the way the diffs are printed.
2020-11-14 16:44:16 +01:00
Mark Karpov
286afb7ed6 Avoid inserting a redundant space in front of ticked types
In certain cases spaces in this position are unnecessary. Here we try to
make the algorithm smarter so that it doesn't always insert spaces.
2020-11-11 14:33:23 +01:00
Greg Pfeil
288e1cc039 Add support for monad comprehensions 2020-11-11 00:57:32 +01:00
Mark Martynov
64735598c7 Fix multiline record dot updates with the record dot plugin 2020-11-01 14:17:15 +01:00
Mark Karpov
c883856849 Make single-line explicit bidirectional pattern synonyms idempotent 2020-09-21 22:45:36 +02:00
Mark Karpov
a38b0096b9 Guarantee a space before ticked promoted types 2020-09-21 22:27:32 +02:00
Mark Karpov
68c3147f5e Improve grouping of top-level type signatures 2020-06-26 14:04:47 +02:00
Mark Karpov
e29dd2b1c7 Fix the bug when comments in different styles get glued together 2020-06-24 17:10:54 +02:00
Mark Karpov
ca83f15869 Implement merging on imports 2020-06-22 16:31:26 +02:00
Mark Karpov
be1eac66c3 Implement merging of the items in import sections 2020-06-19 17:39:23 +02:00
Mark Karpov
e09fcc0316 Fix the bug related to de-association of pragma comments 2020-06-18 13:59:04 +02:00
Mark Karpov
3fc444a70b Fixed the bug in the de-duplicating algorithm for import lists 2020-06-17 16:50:32 +02:00
Mark Karpov
cc337bda18 Prevent type applications from gluing to TH splices that follow them 2020-06-15 12:12:23 +02:00
Mark Karpov
a877785709 Preserve blank lines in ‘let’ and ‘where’ bindings 2020-06-15 10:56:03 +02:00
Mark Karpov
d5a5bf66c0 Fix rendering of function arguments in multiline layout 2020-06-10 15:14:46 +02:00
Mark Karpov
2efc5d37f9 Format linked lists with colon as line terminator
This adds support for a formatting style described here:

<https://wiki.haskell.org/List_notation>
2020-06-10 14:31:07 +02:00
Mark Karpov
903d8d9eef Avoid outputting trailing whitespace in multiline comments 2020-06-04 16:50:47 +02:00
Mark Karpov
2b1d013d7c Put operators after other names
Previously ‘RdrName’s were sorted by simple comparison of their names.
However, in ASCII not all “operator-like” symbols go after alpha-numeric
characters. This resulted in this sort of output:

  import Linear.Vector ((*^), Additive (..), (^*))

The new ordering scheme allows us to separate operators and other names:

  import Linear.Vector (Additive (..), (*^), (^*))
2020-06-03 17:39:12 +02:00
Mark Karpov
67e43e0057 Handle magic comments for disabling/enabling with more flexibility 2020-06-03 15:28:57 +02:00
Jonas
9e11a5c1b2 Remove duplicate LIE's from import lists 2020-05-26 12:04:53 +02:00
Mark Karpov
8eac6bb7a0 Fix an idempotence issue with operators chains 2020-05-25 16:19:37 +02:00
Mark Karpov
1fb65a218c Fix non-idempotent transformation of partly documented data definition 2020-05-15 12:21:27 +02:00
Mark Karpov
b0092e11a1 Fix another case of non-idempotence with inline comments 2020-05-14 15:45:01 +02:00
Mark Karpov
76c4f523d7 Fix rendering of unnamed fields of data constructors 2020-05-13 15:37:07 +02:00
Mark Karpov
a5c4d6c439 Improve rendering of comments around if expressions 2020-05-11 16:47:37 +02:00
Mark Karpov
6ecae36922 Fix the false positive about AST differences
Comments that have more than one consecutive blank line will be rendered
with just a single blank line due to how our rendering engine works. I think
that the engine work correctly in this case and we want to generally
normalize blank lines. So what should be fixed is just the check. For that
we remove extra consecutive blank lines when we construct ‘Comment’ values.
2020-05-11 13:58:48 +02:00
Mark Karpov
60752a2853 Fixed an idempotence issue in type synonym and data declarations 2020-05-07 19:29:52 +02:00
Mark Karpov
0abedcce03 Prevent the equality sign from “disconnecting” comments
This resolves a class of idempotence issues when the equality sign happens
to be inserted between an element and its comment that follows on the same
line. I had to special-case equality sign for this, because all alternative
approaches (changing comment association logic or trying to find a more
general rule) did not work or fixed this issue yet made other things worse.

There is nothing special about the equality sign per se, but it (always?)
starts definitions which have their own ‘Located’ wrappers and it is those
spans interfere with the logic of comment association (they are detected as
AST elements between the “host” element and its comment) on subsequent
passes. This results in non-idempotent formatting.

The solution is OKish in that it fixes 99% of problems that one will
encounter in practice, but I see how an input can be crafted to show that
there is still an issue with idempotence.
2020-05-06 23:03:57 +02:00
Mark Karpov
194da3a19f Fix the difference in indentation levels in a comment series 2020-05-05 14:05:24 +02:00
Mark Karpov
991bf8e24d Prevent incorrect detection of continuations of comment series 2020-05-04 19:02:42 +02:00
Mark Karpov
22839ed74c Improve tracking of dirty lines, better hang expressions in records 2020-04-29 18:12:42 +02:00
Mark Karpov
ae789a41b0 Fix rendering of type signatures concerning several identifiers
Previously an extra space were erroneously inserted if the first identifier
happened to be one character long.
2020-04-26 22:44:57 +02:00
Mark Karpov
21dd3775e7 Fix rendering of module headers 2020-04-24 20:21:35 +02:00
Mark Karpov
ec1a432eed Add a CPP macro continuation test 2020-04-22 15:48:53 +02:00
Mark Karpov
53f582a575
Implement experimental support for CPP 2020-04-22 14:47:09 +02:00
Mark Karpov
dde7560291 Allow disabling of Ormolu with special comments
Ormolu can be turned on and off via the special comments:

{- ORMOLU_DISABLE -}

and

{- ORMOLU_ENABLE -}

This allows us to disable formatting selectively for code between these
markers or disable it for the entire file. To achieve the latter, just put
{- ORMOLU_DISABLE -} at the very top. Note that the source code should still
be parseable even without the “excluded” part. Because of that the magic
comments cannot be placed arbitrary, but should rather enclose independent
top-level definitions.
2020-04-21 12:44:39 +02:00
Mark Karpov
c364a30555 Preserve grouping of TH splices 2020-04-20 14:06:22 +02:00
Mark Karpov
490720fedc Preserve comments on pragmas 2020-04-17 17:01:34 +02:00
Mark Karpov
145f7296f5 Preserve grouping of do statements 2020-04-16 20:41:36 +02:00
Mark Karpov
d09429f6ec Format records with a single data constructor more compactly 2020-04-10 18:02:26 +02:00
Mark Karpov
d96f7e3e00 Do not lump together forall and constructors when deciding on layout 2020-04-10 14:37:15 +02:00
Mark Karpov
9b342488be Render type applications similar to value applications 2020-04-10 14:37:15 +02:00
Mark Karpov
9b7b6eb239 Fix rendering of arrow notation with multiline expressions 2020-04-10 12:42:05 +02:00