Skip to content
This repository was archived by the owner on Oct 7, 2020. It is now read-only.

Ormolu 8.8 #1579

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 2 additions & 4 deletions src/Haskell/Ide/Engine/Plugin/Ormolu.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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))
Expand All @@ -43,4 +41,4 @@ provider _contents _uri _typ _opts =
Right new -> return $ IdeResultOk [TextEdit (fullRange _contents) new]
#else
return $ IdeResultOk [] -- NOP formatter
#endif
#endif
2 changes: 1 addition & 1 deletion stack-8.6.1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion stack-8.6.2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion stack-8.6.3.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion stack-8.6.4.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion stack-8.6.5.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 3 additions & 2 deletions stack-8.8.1.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion stack.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 5 additions & 3 deletions test/functional/FormatSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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\
Expand Down