From 17ccaf4bc511e6317d62cc705c1df9864b9cebb9 Mon Sep 17 00:00:00 2001 From: Avi Dessauer Date: Sun, 19 Jan 2020 19:43:49 -0500 Subject: [PATCH 1/5] Use ormolu git fork on 8.8 & bump nightly --- stack-8.8.1.yaml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/stack-8.8.1.yaml b/stack-8.8.1.yaml index 7e6e43360..156f212c9 100644 --- a/stack-8.8.1.yaml +++ b/stack-8.8.1.yaml @@ -1,10 +1,12 @@ -resolver: nightly-2020-01-17 +resolver: nightly-2020-01-19 packages: - . - hie-plugin-api extra-deps: # - ./submodules/HaRe +- git: https://github.com/Avi-D-coder/ormolu.git + commit: e2968da568b0402b67f36b34f992573519704044 - apply-refact-0.7.0.0 - bytestring-trie-0.2.5.0 @@ -14,7 +16,6 @@ extra-deps: - floskell-0.10.2 - haddock-api-2.23.0 - haddock-library-1.8.0 -- hie-bios-0.3.2 - hoogle-5.0.17.11 - hsimport-0.11.0 - semigroups-0.18.5 From 7b9b80404575a15ae3c34c7c1810126891097ef8 Mon Sep 17 00:00:00 2001 From: Avi Dessauer Date: Sun, 19 Jan 2020 20:12:30 -0500 Subject: [PATCH 2/5] Update to ormolu 0.0.3.0 --- src/Haskell/Ide/Engine/Plugin/Ormolu.hs | 6 ++---- stack-8.6.1.yaml | 2 +- stack-8.6.2.yaml | 2 +- stack-8.6.3.yaml | 2 +- stack-8.6.4.yaml | 2 +- stack-8.6.5.yaml | 2 +- stack-8.8.1.yaml | 2 +- stack.yaml | 2 +- 8 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/Haskell/Ide/Engine/Plugin/Ormolu.hs b/src/Haskell/Ide/Engine/Plugin/Ormolu.hs index 9166f66c8..70ee18c0a 100644 --- a/src/Haskell/Ide/Engine/Plugin/Ormolu.hs +++ b/src/Haskell/Ide/Engine/Plugin/Ormolu.hs @@ -12,8 +12,6 @@ import Control.Monad.IO.Class ( liftIO , MonadIO(..) ) import Data.Aeson ( Value ( Null ) ) import Data.Text import Ormolu -import Ormolu.Config (defaultConfig) -import Ormolu.Exception (OrmoluException) import Haskell.Ide.Engine.PluginUtils #endif @@ -34,7 +32,7 @@ ormoluDescriptor plId = PluginDescriptor provider :: FormattingProvider provider _contents _uri _typ _opts = #if __GLASGOW_HASKELL__ >= 806 - case _typ of + case _typ of FormatRange _ -> return $ IdeResultFail (IdeError PluginError (pack "Selection formatting for Ormolu is not currently supported.") Null) FormatText -> pluginGetFile _contents _uri $ \file -> do result <- liftIO $ try @OrmoluException (ormolu defaultConfig file (unpack _contents)) @@ -43,4 +41,4 @@ provider _contents _uri _typ _opts = Right new -> return $ IdeResultOk [TextEdit (fullRange _contents) new] #else return $ IdeResultOk [] -- NOP formatter -#endif \ No newline at end of file +#endif diff --git a/stack-8.6.1.yaml b/stack-8.6.1.yaml index c6322d553..c7ec40454 100644 --- a/stack-8.6.1.yaml +++ b/stack-8.6.1.yaml @@ -38,7 +38,7 @@ extra-deps: - monoid-subclasses-0.4.6.1 - multistate-0.8.0.1 - parser-combinators-1.2.1 -- ormolu-0.0.2.0 +- ormolu-0.0.3.0 - primes-0.2.1.0 - resolv-0.1.1.2 - rope-utf16-splay-0.3.1.0 diff --git a/stack-8.6.2.yaml b/stack-8.6.2.yaml index 6f2cc5d78..326e29a53 100644 --- a/stack-8.6.2.yaml +++ b/stack-8.6.2.yaml @@ -33,7 +33,7 @@ extra-deps: - monad-memo-0.4.1 - multistate-0.8.0.1 - parser-combinators-1.2.1 -- ormolu-0.0.2.0 +- ormolu-0.0.3.0 - rope-utf16-splay-0.3.1.0 - strict-list-0.1.5 - syz-0.2.0.0 diff --git a/stack-8.6.3.yaml b/stack-8.6.3.yaml index 38e97c28e..20036d0cf 100644 --- a/stack-8.6.3.yaml +++ b/stack-8.6.3.yaml @@ -31,7 +31,7 @@ extra-deps: - multistate-0.8.0.1 - optparse-simple-0.1.0 - parser-combinators-1.2.1 -- ormolu-0.0.2.0 +- ormolu-0.0.3.0 - rope-utf16-splay-0.3.1.0 - syz-0.2.0.0 - temporary-1.2.1.1 diff --git a/stack-8.6.4.yaml b/stack-8.6.4.yaml index 6b2d30d34..be9647f14 100644 --- a/stack-8.6.4.yaml +++ b/stack-8.6.4.yaml @@ -29,7 +29,7 @@ extra-deps: - monad-memo-0.4.1 - multistate-0.8.0.1 - parser-combinators-1.2.1 -- ormolu-0.0.2.0 +- ormolu-0.0.3.0 - rope-utf16-splay-0.3.1.0 - syz-0.2.0.0 - temporary-1.2.1.1 diff --git a/stack-8.6.5.yaml b/stack-8.6.5.yaml index ebd4305de..8e6ce0947 100644 --- a/stack-8.6.5.yaml +++ b/stack-8.6.5.yaml @@ -27,7 +27,7 @@ extra-deps: - lsp-test-0.10.0.0 - monad-dijkstra-0.1.1.2@rev:1 - parser-combinators-1.2.1 -- ormolu-0.0.2.0 +- ormolu-0.0.3.0 - syz-0.2.0.0 - temporary-1.2.1.1 diff --git a/stack-8.8.1.yaml b/stack-8.8.1.yaml index 156f212c9..29799433a 100644 --- a/stack-8.8.1.yaml +++ b/stack-8.8.1.yaml @@ -6,7 +6,7 @@ packages: extra-deps: # - ./submodules/HaRe - git: https://github.com/Avi-D-coder/ormolu.git - commit: e2968da568b0402b67f36b34f992573519704044 + commit: dbd93d753cf5370620e235fea91cc029f2e988fb - apply-refact-0.7.0.0 - bytestring-trie-0.2.5.0 diff --git a/stack.yaml b/stack.yaml index b97f0b2fd..52ae5e118 100644 --- a/stack.yaml +++ b/stack.yaml @@ -28,7 +28,7 @@ extra-deps: - lsp-test-0.10.0.0 - monad-dijkstra-0.1.1.2@rev:1 - parser-combinators-1.2.1 -- ormolu-0.0.2.0 +- ormolu-0.0.3.0 - syz-0.2.0.0 - temporary-1.2.1.1 - unix-compat-0.5.2 From c2a96b168b5e1e4c4b0e76bf5d8848b2d7960b0d Mon Sep 17 00:00:00 2001 From: Avi Dessauer Date: Sun, 19 Jan 2020 20:37:32 -0500 Subject: [PATCH 3/5] Use ormolu git fork with cabal --- cabal.project | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cabal.project b/cabal.project index c8c3c4b03..0e9b4bfea 100644 --- a/cabal.project +++ b/cabal.project @@ -17,3 +17,8 @@ constraints: write-ghc-environment-files: never index-state: 2020-01-07T22:09:46Z + +source-repository-package + type: git + location: https://github.com/Avi-D-coder/ormolu.git + tag: dbd93d753cf5370620e235fea91cc029f2e988fb From c609bcef08e87656d757de887eb0ca83a873badb Mon Sep 17 00:00:00 2001 From: Avi Dessauer Date: Mon, 20 Jan 2020 00:12:04 -0500 Subject: [PATCH 4/5] Relax ormolu base lower bound --- cabal.project | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cabal.project b/cabal.project index 0e9b4bfea..2a6bc29e4 100644 --- a/cabal.project +++ b/cabal.project @@ -18,6 +18,8 @@ write-ghc-environment-files: never index-state: 2020-01-07T22:09:46Z +allow-older: ormolu:base + source-repository-package type: git location: https://github.com/Avi-D-coder/ormolu.git From cd7281e008072157ca74b4ae7ba0c584698eee2f Mon Sep 17 00:00:00 2001 From: Avi Dessauer Date: Mon, 20 Jan 2020 03:02:20 -0500 Subject: [PATCH 5/5] Update ormolu test --- test/functional/FormatSpec.hs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/test/functional/FormatSpec.hs b/test/functional/FormatSpec.hs index 704d62a39..b65ebce80 100644 --- a/test/functional/FormatSpec.hs +++ b/test/functional/FormatSpec.hs @@ -95,14 +95,16 @@ spec = do describe "ormolu" $ do let formatLspConfig provider = object [ "languageServerHaskell" .= object ["formattingProvider" .= (provider :: Value)] ] - + it "formats correctly" $ runSession hieCommand fullCaps "test/testdata" $ do sendNotification WorkspaceDidChangeConfiguration (DidChangeConfigurationParams (formatLspConfig "ormolu")) doc <- openDoc "Format.hs" "haskell" formatDoc doc (FormattingOptions 2 True) docContent <- documentContents doc + let formatted = liftIO $ docContent `shouldBe` formattedOrmolu case ghcVersion of - GHC86 -> liftIO $ docContent `shouldBe` formattedOrmolu + GHC86 -> formatted + GHC88 -> formatted _ -> liftIO $ docContent `shouldBe` unchangedOrmolu @@ -193,7 +195,7 @@ formattedOrmolu = \ return \"asdf\"\n" unchangedOrmolu :: T.Text -unchangedOrmolu = +unchangedOrmolu = "module Format where\n\ \foo :: Int -> Int\n\ \foo 3 = 2\n\