1
1
mirror of https://github.com/google/ormolu.git synced 2024-09-11 08:05:24 +03:00
Commit Graph

383 Commits

Author SHA1 Message Date
Facundo Domínguez
5bffeffa05 Update design notes for CPP. 2020-04-24 23:08:37 +02:00
Mark Karpov
fc64eada5c
Version bump (0.0.5.0)
[skip ci]
2020-04-24 20:23:36 +02:00
Mark Karpov
21dd3775e7 Fix rendering of module headers 2020-04-24 20:21:35 +02:00
Mark Karpov
840acd908b Allow selection of a region to format 2020-04-24 19:01:30 +02:00
Mark Karpov
39059761a5
Avoid re-compilation of ormolu for hackage test targets
Previously running tests took longer and this is why we have this
conditional. I doubt it was a good idea anyway, because the ‘dontCheck’
modifier causes re-compilation which takes longer than running tests anyway.
2020-04-23 21:06:08 +02:00
Mark Karpov
70978c6a9c Define ‘attachRelativePos’ in ‘Ormolu.Utils’, refactor 2020-04-23 17:14:23 +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
2fa7078346
Mention grouping of TH splices in the changelog
[skip ci]
2020-04-20 14:54:03 +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
44cef926de Improve the error message in case of a parse error (take 2) 2020-04-16 12:20:20 +02:00
Mark Karpov
ab179d5a17 Improve the error message in case of a parse error
Parse errors are typically not Ormolu errors.
2020-04-15 19:07:57 +02:00
Mark Karpov
0e40431ba3
Ignore blank lines when checking the logs for Hackage packages
My editor trims trailing blank lines, so it is not handy to edit the
expected failures manually.
2020-04-15 17:56:31 +02:00
Mark Karpov
683cbeacf5
Version bump (0.0.4.0)
[skip ci]
2020-04-15 15:52:50 +02:00
Mark Karpov
f38854c357
Update the ‘tested-with’ field in the cabal file 2020-04-15 15:05:38 +02:00
Mark Karpov
31f6cfd83f Compare failing logs with exact expected result
This will allow us to test on more code and catch changes in the logs as
they happen.
2020-04-15 15:00:08 +02:00
Mark Karpov
9874ac7ce7
Some minor edits to the changelog
[skip ci]
2020-04-14 22:41:47 +02:00
Mark Karpov
1e089f7dc8 Run the build with 3 latest GHC versions 2020-04-14 18:23:56 +02:00
Utku Demir
e7c080e2aa Fix GHC panic on showOutputable
Closes #544.

It looks like when we call 'showSDocUnsafe' it uses `unsafeGlobalDynFlags`
wwhich the `settings` field is not initialised unless someone calls
`setUnsafeGlobalDynFlags`, `initGhcMonad` or `runGhc` and throws a panic.

I couldn't pinpoint the exact cause, but I suspect probably there was
a change either on Ormolu or ghc-lib-parser which removed a call to one
of the functions above before we print manualExts.

Anyway, we actually don't need to call `showSDocUnsafe` since we already
have a populated `DynFlags`. This commit removes the unsafe call and passes
the `DynFlags` we have to `showSDoc`.
2020-04-14 00:18:30 +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
Mark Karpov
ea2d80ed65
Remove redundant imports
When the problem with ‘dev’ flag is fixed this will be enforced on CI
properly. For now it is just too annoying to see all the warnings.
2020-04-10 12:17:29 +02:00
Mark Karpov
5acda489e8
Add the recent changes to the changelog
[skip ci]
2020-04-09 18:37:02 +02:00
Dmitry Ivanov
27d4ae199e Compile the executable with -rtsopts 2020-04-09 10:05:24 +02:00
Utku Demir
100fa44dbb Respect the ‘ImportQualifiedPost’ language extension
It is tempting to enable ‘ImportQualifiedPost’ automatically for all files,
but in that case we won't be able to tell when to format in the
classical (prefix) style vs the new postfix style. Checking the list of
pragmas on per-file basis is not good enough because the extension can be
enabled in other ways, such as via the --ghc-opt flag.
2020-04-05 12:22:07 +02:00
Utku Demir
b0a261fe5b Support StandaloneKindSignatures 2020-04-05 11:06:32 +02:00
Utku Demir
2c5472944b Update ghc-lib-parser to 8.10.1
GHC 8.10.1 comes with some changes to the AST, which works great for
Ormolu, but causes this commit to be a bit large:

* Trees That Grow extension points for new constructors are now statically
  proven to be uninhabited, via noExtCon :: NoExtCon -> a. Thanks to this
  change I got rid of many notImplemented calls.
* LPat constructor is now a lot more usable, so we don't need to use
  the locatedPat combinator and can remove some boilerplate code.

Also it comes with ImportQualifiedPost and StandaloneKindSignatures
we should support. I did not implement them in this commit, they'll
be merged in later on.

It causes one behaviour change, where the ordering of qualified and
non-qualified imports of the same module is changed. This is due to
our usage of gcompare resulting a different ordering because of the
AST change caused by the ImportQualifiedPost extension. I think this is
acceptable and we shouldn't try to keep backwards compatibility there.

Another behaviour change is that previously HsExpr had a few extra
constructors for arrows and patterns used in expression context. Those
programs were syntactically incorrect, but refused on a later stage. But
we nonetheless formatted those constructs so Ormolu didn't fail there
while keeping the source code intact. However, now those constructors
are removed, so Ormolu fails with a parse error in this case (same as
GHC). I also removed some tests exhibiting this behaviour.
2020-04-05 10:53:40 +02:00
Clément Hurlin
57d0d11b37 Mention a second vim integration: neoformat 2020-03-26 23:36:51 +01:00
fisx
55d8b7f8c4 Add link to vim integration to README 2020-02-18 12:59:57 +01:00
Mark Karpov
231b93c5d4
Drop -Wnoncanonical-monadfail-instances 2020-02-12 14:59:11 +01:00
Mark Karpov
ba381734f3
Drop a debugging line from the Buildkite pipeline 2020-02-11 11:59:26 +01:00
Mark Karpov
5f5a70655a Use Buildkite
Replace CircleCI with Buildkite.
2020-02-10 20:17:49 +01:00
Mark Karpov
ac719f3e99 Improve rendering of "where" in class declarations and such 2020-02-10 11:21:34 +01:00
Mark Karpov
84c2a53349 More compact rendering of type family injectivity constraints 2020-02-01 20:03:41 +01:00
Mark Karpov
a37765cbcb Make rendering of operator patterns consistent with other cases 2020-01-31 14:36:40 +01:00
Utku Demir
34dc1cba49 Don't give up on first failure when multiple files are given
Closes #502.
2020-01-30 13:43:59 +01:00
Mark Karpov
a9f8926c8d Format the source of the application as well 2020-01-24 16:42:21 +01:00
Mark Karpov
d1c7606cab
Version bump (0.0.3.1)
[skip ci]
2020-01-22 19:17:34 +01:00
Avi Dessauer
c1ea571fd3 Bump version bounds 2020-01-22 19:15:43 +01:00
Mark Karpov
ca8cb0474a
Add a mention of the issue 498 to the changelog
[skip ci]
2020-01-17 12:06:43 +01:00
Avi Dessauer
77424882fd Differentiate recordDot & standard record updates 2020-01-17 11:12:08 +01:00
Mark Karpov
3137345dc3
Version bump (0.0.3.0)
[skip ci]
2020-01-11 13:06:12 +01:00
Sridhar Ratnakumar
116fe842b4 Preserve newlines in class and instance declarations
Preserve user-added newlines with the following normalizations:

* No newlines below where
* Consecutive newlines are compressed into a single newline
* Always surround documented declarations with blank lines
2020-01-11 13:05:18 +01:00
Mark Karpov
6ee0365f2c Fix indentation in presence of type applications 2020-01-10 16:53:29 +01:00
Mark Karpov
1eefa97cc2 Do not hang record constructors
Previously we hanged record constructors but not record updates. It looks
like unlike other hanging constructions (lambdas, case expressions, and
do-blocks), record constructors and updates should rather be placed
normally. Indeed, when we stop hanging them, many constructions start to
look more reasonable and predictable (see the updated test cases).

Yet the change is not enough to fix the problem in general case: it is
enough to replace the record with a e.g. do-block to get the same failure.
To correct that we adjust what should fit in one line for hanging placement
to fire: now we consider the span between beginning of function and the
start of potentially-hanging construction.
2020-01-09 20:43:33 +01:00