diff --git a/cabal.project b/cabal.project index c8c3c4b03..2a6bc29e4 100644 --- a/cabal.project +++ b/cabal.project @@ -17,3 +17,10 @@ constraints: 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 + tag: dbd93d753cf5370620e235fea91cc029f2e988fb 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 7e6e43360..29799433a 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: dbd93d753cf5370620e235fea91cc029f2e988fb - 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 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 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\