From d5e256a746e7def261750f1b794e52b9f0cff89b Mon Sep 17 00:00:00 2001 From: George Thomas Date: Sat, 1 Aug 2020 01:06:55 +0100 Subject: [PATCH 01/14] Add fourmolu plugin --- cabal.project | 4 + exe/Main.hs | 6 +- haskell-language-server.cabal | 2 + src/Ide/Plugin/Fourmolu.hs | 95 +++++++++++++++++++++ src/Ide/Plugin/Ormolu.hs | 3 +- stack-8.10.1.yaml | 1 + stack-8.6.4.yaml | 1 + stack-8.6.5.yaml | 1 + stack-8.8.2.yaml | 1 + stack-8.8.3.yaml | 1 + stack-8.8.4.yaml | 1 + test/functional/Format.hs | 15 ++++ test/testdata/Format.fourmolu.formatted.hs | 16 ++++ test/testdata/Format2.fourmolu.formatted.hs | 5 ++ 14 files changed, 149 insertions(+), 3 deletions(-) create mode 100644 src/Ide/Plugin/Fourmolu.hs create mode 100644 test/testdata/Format.fourmolu.formatted.hs create mode 100644 test/testdata/Format2.fourmolu.formatted.hs diff --git a/cabal.project b/cabal.project index c063a3fc3e..c28b76d41a 100644 --- a/cabal.project +++ b/cabal.project @@ -15,3 +15,7 @@ package ghcide write-ghc-environment-files: never index-state: 2020-07-27T12:40:45Z + +allow-newer: + floskell:aeson + stylish-haskell:aeson diff --git a/exe/Main.hs b/exe/Main.hs index a13d4d875f..8224d3d7bc 100644 --- a/exe/Main.hs +++ b/exe/Main.hs @@ -67,6 +67,7 @@ import Ide.Plugin.Example as Example import Ide.Plugin.Example2 as Example2 import Ide.Plugin.GhcIde as GhcIde import Ide.Plugin.Floskell as Floskell +import Ide.Plugin.Fourmolu as Fourmolu import Ide.Plugin.Ormolu as Ormolu import Ide.Plugin.StylishHaskell as StylishHaskell import Ide.Plugin.Retrie as Retrie @@ -102,8 +103,9 @@ idePlugins includeExamples = pluginDescToIdePlugins allPlugins GhcIde.descriptor "ghcide" , Pragmas.descriptor "pragmas" , Floskell.descriptor "floskell" - -- , genericDescriptor "generic" - -- , ghcmodDescriptor "ghcmod" + , Fourmolu.descriptor "fourmolu" + -- , genericDescriptor "generic" + -- , ghcmodDescriptor "ghcmod" , Ormolu.descriptor "ormolu" , StylishHaskell.descriptor "stylish-haskell" , Retrie.descriptor "retrie" diff --git a/haskell-language-server.cabal b/haskell-language-server.cabal index 3543db1c7e..266b266dc4 100644 --- a/haskell-language-server.cabal +++ b/haskell-language-server.cabal @@ -45,6 +45,7 @@ library Ide.Plugin.Eval Ide.Plugin.Example Ide.Plugin.Example2 + Ide.Plugin.Fourmolu Ide.Plugin.GhcIde Ide.Plugin.Ormolu Ide.Plugin.Pragmas @@ -72,6 +73,7 @@ library , extra , filepath , floskell == 0.10.* + , fourmolu ^>= 0.1 , ghc , ghc-boot-th , ghcide >= 0.1 diff --git a/src/Ide/Plugin/Fourmolu.hs b/src/Ide/Plugin/Fourmolu.hs new file mode 100644 index 0000000000..07d4272b95 --- /dev/null +++ b/src/Ide/Plugin/Fourmolu.hs @@ -0,0 +1,95 @@ +{-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE PackageImports #-} +{-# LANGUAGE RecordWildCards #-} +{-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE TypeApplications #-} + +module Ide.Plugin.Fourmolu + ( + descriptor + , provider + ) +where + +import Control.Exception +import qualified Data.Text as T +import Development.IDE.Core.Rules +import Development.IDE.Core.RuleTypes (GhcSession (GhcSession)) +import Development.IDE.Core.Shake (use) +import Development.IDE.GHC.Util (hscEnv) +import Development.IDE.Types.Diagnostics as D +import Development.IDE.Types.Location +import qualified DynFlags as D +import qualified EnumSet as S +import GHC +import GHC.LanguageExtensions.Type +import GhcPlugins (HscEnv (hsc_dflags)) +import Ide.Plugin.Formatter +import Ide.PluginUtils +import Ide.Types +import Language.Haskell.LSP.Core (LspFuncs (withIndefiniteProgress), + ProgressCancellable (Cancellable)) +import Language.Haskell.LSP.Types +import "fourmolu" Ormolu +import System.FilePath (takeFileName) +import Text.Regex.TDFA.Text () + +-- --------------------------------------------------------------------- + +descriptor :: PluginId -> PluginDescriptor +descriptor plId = (defaultPluginDescriptor plId) + { pluginFormattingProvider = Just provider + } + +-- --------------------------------------------------------------------- + +provider :: FormattingProvider IO +provider lf ideState typ contents fp _ = withIndefiniteProgress lf title Cancellable $ do + let + fromDyn :: DynFlags -> IO [DynOption] + fromDyn df = + let + pp = + let p = D.sPgm_F $ D.settings df + in if null p then [] else ["-pgmF=" <> p] + pm = map (("-fplugin=" <>) . moduleNameString) $ D.pluginModNames df + ex = map showExtension $ S.toList $ D.extensionFlags df + in + return $ map DynOption $ pp <> pm <> ex + + ghc <- runAction "Fourmolu" ideState $ use GhcSession fp + let df = hsc_dflags . hscEnv <$> ghc + fileOpts <- case df of + Nothing -> return [] + Just df -> fromDyn df + + let + fullRegion = RegionIndices Nothing Nothing + rangeRegion s e = RegionIndices (Just $ s + 1) (Just $ e + 1) + mkConf o region = do + printerOpts <- loadConfigFile True (Just fp') defaultPrinterOpts + return $ defaultConfig + { cfgDynOptions = o + , cfgRegion = region + , cfgDebug = True + , cfgPrinterOpts = printerOpts + } + fmt :: T.Text -> Config RegionIndices -> IO (Either OrmoluException T.Text) + fmt cont conf = + try @OrmoluException (ormolu conf fp' $ T.unpack cont) + fp' = fromNormalizedFilePath fp + + case typ of + FormatText -> ret <$> (fmt contents =<< mkConf fileOpts fullRegion) + FormatRange (Range (Position sl _) (Position el _)) -> + ret <$> (fmt contents =<< mkConf fileOpts (rangeRegion sl el)) + where + title = T.pack $ "Formatting " <> takeFileName (fromNormalizedFilePath fp) + ret :: Either OrmoluException T.Text -> Either ResponseError (List TextEdit) + ret (Left err) = Left + (responseError (T.pack $ "fourmoluCmd: " ++ show err) ) + ret (Right new) = Right (makeDiffTextEdit contents new) + +showExtension :: Extension -> String +showExtension Cpp = "-XCPP" +showExtension other = "-X" ++ show other diff --git a/src/Ide/Plugin/Ormolu.hs b/src/Ide/Plugin/Ormolu.hs index dcfad0b16a..e5d268232b 100644 --- a/src/Ide/Plugin/Ormolu.hs +++ b/src/Ide/Plugin/Ormolu.hs @@ -1,4 +1,5 @@ {-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE PackageImports #-} {-# LANGUAGE RecordWildCards #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeApplications #-} @@ -29,7 +30,7 @@ import Ide.Types import Language.Haskell.LSP.Core (LspFuncs (withIndefiniteProgress), ProgressCancellable (Cancellable)) import Language.Haskell.LSP.Types -import Ormolu +import "ormolu" Ormolu import System.FilePath (takeFileName) import Text.Regex.TDFA.Text () diff --git a/stack-8.10.1.yaml b/stack-8.10.1.yaml index 8d62e3c008..775d05cbba 100644 --- a/stack-8.10.1.yaml +++ b/stack-8.10.1.yaml @@ -13,6 +13,7 @@ extra-deps: - cabal-plan-0.7.0.0 - clock-0.7.2 - floskell-0.10.3 +- fourmolu-0.1.0.0 - ghc-exactprint-0.6.3 - lens-4.19.1 - lsp-test-0.11.0.3 diff --git a/stack-8.6.4.yaml b/stack-8.6.4.yaml index 307f1a86b9..c29dc76d0e 100644 --- a/stack-8.6.4.yaml +++ b/stack-8.6.4.yaml @@ -18,6 +18,7 @@ extra-deps: - clock-0.7.2 - extra-1.7.3 - floskell-0.10.3 +- fourmolu-0.1.0.0 - fuzzy-0.1.0.0 # - ghcide-0.1.0 - ghc-check-0.5.0.1 diff --git a/stack-8.6.5.yaml b/stack-8.6.5.yaml index fe45cb734a..1ddef08e96 100644 --- a/stack-8.6.5.yaml +++ b/stack-8.6.5.yaml @@ -17,6 +17,7 @@ extra-deps: - clock-0.7.2 - extra-1.7.3 - floskell-0.10.3 +- fourmolu-0.1.0.0 - fuzzy-0.1.0.0 # - ghcide-0.1.0 - ghc-check-0.5.0.1 diff --git a/stack-8.8.2.yaml b/stack-8.8.2.yaml index 0d3b2d5ca3..7a0f5ebe19 100644 --- a/stack-8.8.2.yaml +++ b/stack-8.8.2.yaml @@ -16,6 +16,7 @@ extra-deps: - constrained-dynamic-0.1.0.0 - extra-1.7.3 - floskell-0.10.3 +- fourmolu-0.1.0.0 # - ghcide-0.1.0 - ghc-check-0.5.0.1 - ghc-lib-parser-8.10.1.20200523 diff --git a/stack-8.8.3.yaml b/stack-8.8.3.yaml index 71a81374c1..960a50f13d 100644 --- a/stack-8.8.3.yaml +++ b/stack-8.8.3.yaml @@ -15,6 +15,7 @@ extra-deps: - constrained-dynamic-0.1.0.0 - extra-1.7.3 - floskell-0.10.3 +- fourmolu-0.1.0.0 # - ghcide-0.1.0 - haskell-src-exts-1.21.1 - hie-bios-0.6.1 diff --git a/stack-8.8.4.yaml b/stack-8.8.4.yaml index d2f1d8449a..9997bb3518 100644 --- a/stack-8.8.4.yaml +++ b/stack-8.8.4.yaml @@ -17,6 +17,7 @@ extra-deps: - constrained-dynamic-0.1.0.0 - extra-1.7.3 - floskell-0.10.3 +- fourmolu-0.1.0.0 # - ghcide-0.1.0 - haskell-src-exts-1.21.1 - hie-bios-0.6.1 diff --git a/test/functional/Format.hs b/test/functional/Format.hs index 11fc65123d..0ebac31071 100644 --- a/test/functional/Format.hs +++ b/test/functional/Format.hs @@ -36,6 +36,7 @@ tests = testGroup "format document" [ , brittanyTests #endif , ormoluTests + , fourmoluTests ] rangeTests :: TestTree @@ -159,6 +160,20 @@ ormoluTests = testGroup "ormolu" BS.fromStrict . T.encodeUtf8 <$> documentContents doc ] +fourmoluTests :: TestTree +fourmoluTests = testGroup "fourmolu" + [ goldenVsStringDiff "formats correctly" goldenGitDiff "test/testdata/Format.fourmolu.formatted.hs" $ runSession hieCommand fullCaps "test/testdata" $ do + sendNotification WorkspaceDidChangeConfiguration (DidChangeConfigurationParams (formatLspConfig "fourmolu")) + doc <- openDoc "Format.hs" "haskell" + formatDoc doc (FormattingOptions 4 True) + BS.fromStrict . T.encodeUtf8 <$> documentContents doc + , goldenVsStringDiff "formats imports correctly" goldenGitDiff "test/testdata/Format2.fourmolu.formatted.hs" $ runSession hieCommand fullCaps "test/testdata" $ do + sendNotification WorkspaceDidChangeConfiguration (DidChangeConfigurationParams (formatLspConfig "fourmolu")) + doc <- openDoc "Format2.hs" "haskell" + formatDoc doc (FormattingOptions 4 True) + BS.fromStrict . T.encodeUtf8 <$> documentContents doc + ] + formatLspConfig :: Value -> Value formatLspConfig provider = object [ "haskell" .= object ["formattingProvider" .= (provider :: Value)] ] diff --git a/test/testdata/Format.fourmolu.formatted.hs b/test/testdata/Format.fourmolu.formatted.hs new file mode 100644 index 0000000000..41dba5b34d --- /dev/null +++ b/test/testdata/Format.fourmolu.formatted.hs @@ -0,0 +1,16 @@ +module Format where + +import Data.Int +import Data.List +import Prelude + +foo :: Int -> Int +foo 3 = 2 +foo x = x + +bar :: String -> IO String +bar s = do + x <- return "hello" + return "asdf" + +data Baz = Baz {a :: Int, b :: String} diff --git a/test/testdata/Format2.fourmolu.formatted.hs b/test/testdata/Format2.fourmolu.formatted.hs new file mode 100644 index 0000000000..b3d867e700 --- /dev/null +++ b/test/testdata/Format2.fourmolu.formatted.hs @@ -0,0 +1,5 @@ +import Data.Bool +import Data.Char +import Data.Data +import Data.Either +import Data.Int From 1abc7fbf2f2e9d042e8d04c6382b92f690b4ecde Mon Sep 17 00:00:00 2001 From: George Thomas Date: Sat, 1 Aug 2020 01:41:01 +0100 Subject: [PATCH 02/14] Add newer aeson to stack extra-deps --- stack-8.10.1.yaml | 1 + stack-8.6.4.yaml | 1 + stack-8.6.5.yaml | 1 + stack-8.8.2.yaml | 1 + stack-8.8.3.yaml | 1 + stack-8.8.4.yaml | 1 + stack.yaml | 1 + 7 files changed, 7 insertions(+) diff --git a/stack-8.10.1.yaml b/stack-8.10.1.yaml index 775d05cbba..3ef4a1504b 100644 --- a/stack-8.10.1.yaml +++ b/stack-8.10.1.yaml @@ -8,6 +8,7 @@ ghc-options: "$everything": -haddock extra-deps: +- aeson-1.5.2.0 - Cabal-3.0.2.0 - hie-bios-0.6.1 - cabal-plan-0.7.0.0 diff --git a/stack-8.6.4.yaml b/stack-8.6.4.yaml index c29dc76d0e..2707ce389e 100644 --- a/stack-8.6.4.yaml +++ b/stack-8.6.4.yaml @@ -9,6 +9,7 @@ ghc-options: "$everything": -haddock extra-deps: +- aeson-1.5.2.0 - ansi-terminal-0.10.3 - base-compat-0.11.0 - brittany-0.12.1.1@rev:2 diff --git a/stack-8.6.5.yaml b/stack-8.6.5.yaml index 1ddef08e96..883cf3fa10 100644 --- a/stack-8.6.5.yaml +++ b/stack-8.6.5.yaml @@ -8,6 +8,7 @@ ghc-options: "$everything": -haddock extra-deps: +- aeson-1.5.2.0 - ansi-terminal-0.10.3 - base-compat-0.11.0 - brittany-0.12.1.1@rev:2 diff --git a/stack-8.8.2.yaml b/stack-8.8.2.yaml index 7a0f5ebe19..ae5e6d2025 100644 --- a/stack-8.8.2.yaml +++ b/stack-8.8.2.yaml @@ -8,6 +8,7 @@ ghc-options: "$everything": -haddock extra-deps: +- aeson-1.5.2.0 - apply-refact-0.7.0.0 - brittany-0.12.1.1 - butcher-1.3.3.2 diff --git a/stack-8.8.3.yaml b/stack-8.8.3.yaml index 960a50f13d..cccdd58657 100644 --- a/stack-8.8.3.yaml +++ b/stack-8.8.3.yaml @@ -8,6 +8,7 @@ ghc-options: "$everything": -haddock extra-deps: +- aeson-1.5.2.0 - apply-refact-0.7.0.0 - bytestring-trie-0.2.5.0 - cabal-plan-0.6.2.0 diff --git a/stack-8.8.4.yaml b/stack-8.8.4.yaml index 9997bb3518..571ae409cc 100644 --- a/stack-8.8.4.yaml +++ b/stack-8.8.4.yaml @@ -9,6 +9,7 @@ ghc-options: "$everything": -haddock extra-deps: +- aeson-1.5.2.0 - apply-refact-0.7.0.0 - bytestring-trie-0.2.5.0 - cabal-helper-1.1.0.0 diff --git a/stack.yaml b/stack.yaml index a3fb790819..66687aeaca 100644 --- a/stack.yaml +++ b/stack.yaml @@ -8,6 +8,7 @@ ghc-options: "$everything": -haddock extra-deps: +- aeson-1.5.2.0 - ansi-terminal-0.10.3 - base-compat-0.11.0 - brittany-0.12.1.1@rev:2 From b0f652698c129780114a8abf6c9d5b32c30929ff Mon Sep 17 00:00:00 2001 From: George Thomas Date: Sat, 1 Aug 2020 01:51:04 +0100 Subject: [PATCH 03/14] Use allow-newer with stack --- stack-8.10.1.yaml | 2 ++ stack-8.6.4.yaml | 2 ++ stack-8.6.5.yaml | 2 ++ stack-8.8.2.yaml | 2 ++ stack-8.8.3.yaml | 2 ++ stack-8.8.4.yaml | 2 ++ stack.yaml | 2 ++ 7 files changed, 14 insertions(+) diff --git a/stack-8.10.1.yaml b/stack-8.10.1.yaml index 3ef4a1504b..2eccd4a5a7 100644 --- a/stack-8.10.1.yaml +++ b/stack-8.10.1.yaml @@ -43,3 +43,5 @@ nix: packages: [ icu libcxx zlib ] concurrent-tests: false + +allow-newer: true diff --git a/stack-8.6.4.yaml b/stack-8.6.4.yaml index 2707ce389e..2ac44d9749 100644 --- a/stack-8.6.4.yaml +++ b/stack-8.6.4.yaml @@ -67,3 +67,5 @@ nix: packages: [ icu libcxx zlib ] concurrent-tests: false + +allow-newer: true diff --git a/stack-8.6.5.yaml b/stack-8.6.5.yaml index 883cf3fa10..88dc294e97 100644 --- a/stack-8.6.5.yaml +++ b/stack-8.6.5.yaml @@ -66,3 +66,5 @@ nix: packages: [ icu libcxx zlib ] concurrent-tests: false + +allow-newer: true diff --git a/stack-8.8.2.yaml b/stack-8.8.2.yaml index ae5e6d2025..a1576ee984 100644 --- a/stack-8.8.2.yaml +++ b/stack-8.8.2.yaml @@ -56,3 +56,5 @@ nix: packages: [ icu libcxx zlib ] concurrent-tests: false + +allow-newer: true diff --git a/stack-8.8.3.yaml b/stack-8.8.3.yaml index cccdd58657..58afb25990 100644 --- a/stack-8.8.3.yaml +++ b/stack-8.8.3.yaml @@ -44,3 +44,5 @@ nix: packages: [ icu libcxx zlib ] concurrent-tests: false + +allow-newer: true diff --git a/stack-8.8.4.yaml b/stack-8.8.4.yaml index 571ae409cc..c51ce84586 100644 --- a/stack-8.8.4.yaml +++ b/stack-8.8.4.yaml @@ -46,3 +46,5 @@ nix: packages: [ icu libcxx zlib ] concurrent-tests: false + +allow-newer: true diff --git a/stack.yaml b/stack.yaml index 66687aeaca..74680e5e76 100644 --- a/stack.yaml +++ b/stack.yaml @@ -63,3 +63,5 @@ nix: packages: [ icu libcxx zlib ] concurrent-tests: false + +allow-newer: true From fcf3b2cbf28e16e36f2b603b0108d950d151ca53 Mon Sep 17 00:00:00 2001 From: George Thomas Date: Sat, 1 Aug 2020 02:08:36 +0100 Subject: [PATCH 04/14] [skip ci] Revert an accidental comment change --- exe/Main.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/exe/Main.hs b/exe/Main.hs index 8224d3d7bc..612d6e77eb 100644 --- a/exe/Main.hs +++ b/exe/Main.hs @@ -104,8 +104,8 @@ idePlugins includeExamples = pluginDescToIdePlugins allPlugins , Pragmas.descriptor "pragmas" , Floskell.descriptor "floskell" , Fourmolu.descriptor "fourmolu" - -- , genericDescriptor "generic" - -- , ghcmodDescriptor "ghcmod" + -- , genericDescriptor "generic" + -- , ghcmodDescriptor "ghcmod" , Ormolu.descriptor "ormolu" , StylishHaskell.descriptor "stylish-haskell" , Retrie.descriptor "retrie" From 894af50c4db2952ed6e837f79bffd336d2617f9a Mon Sep 17 00:00:00 2001 From: George Thomas Date: Sat, 1 Aug 2020 18:08:40 +0100 Subject: [PATCH 05/14] Update hackage index state In order to bring in Fourmolu revision which widens lower bound on `directory`, for compatibility with older GHCs. --- cabal.project | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cabal.project b/cabal.project index c28b76d41a..17b6a9210e 100644 --- a/cabal.project +++ b/cabal.project @@ -14,7 +14,7 @@ package ghcide write-ghc-environment-files: never -index-state: 2020-07-27T12:40:45Z +index-state: 2020-08-01T17:01:19Z allow-newer: floskell:aeson From e3b88897751b076d766cde23e83d65dc807161bb Mon Sep 17 00:00:00 2001 From: George Thomas Date: Wed, 5 Aug 2020 16:01:07 +0100 Subject: [PATCH 06/14] Bump dependencies, remove allow-newer --- cabal.project | 6 +----- stack-8.10.1.yaml | 9 ++++----- stack-8.6.4.yaml | 10 ++++------ stack-8.6.5.yaml | 10 ++++------ stack-8.8.2.yaml | 10 ++++------ stack-8.8.3.yaml | 8 ++++---- stack-8.8.4.yaml | 8 ++++---- stack.yaml | 9 ++++----- 8 files changed, 29 insertions(+), 41 deletions(-) diff --git a/cabal.project b/cabal.project index 17b6a9210e..2618181aa4 100644 --- a/cabal.project +++ b/cabal.project @@ -14,8 +14,4 @@ package ghcide write-ghc-environment-files: never -index-state: 2020-08-01T17:01:19Z - -allow-newer: - floskell:aeson - stylish-haskell:aeson +index-state: 2020-08-05T14:24:10Z diff --git a/stack-8.10.1.yaml b/stack-8.10.1.yaml index 2eccd4a5a7..52fbc08dc3 100644 --- a/stack-8.10.1.yaml +++ b/stack-8.10.1.yaml @@ -13,16 +13,17 @@ extra-deps: - hie-bios-0.6.1 - cabal-plan-0.7.0.0 - clock-0.7.2 -- floskell-0.10.3 -- fourmolu-0.1.0.0 +- floskell-0.10.4 +- fourmolu-0.1.0.0@rev:1 - ghc-exactprint-0.6.3 +- HsYAML-aeson-0.2.0.0@rev:2 - lens-4.19.1 - lsp-test-0.11.0.3 - monad-dijkstra-0.1.1.2 - optics-core-0.3 - ormolu-0.1.2.0 - retrie-0.1.1.1 -- stylish-haskell-0.11.0.0 +- stylish-haskell-0.11.0.3 - semigroups-0.18.5 - temporary-1.2.1.1 - these-1.1 @@ -43,5 +44,3 @@ nix: packages: [ icu libcxx zlib ] concurrent-tests: false - -allow-newer: true diff --git a/stack-8.6.4.yaml b/stack-8.6.4.yaml index 2ac44d9749..e5ce663d95 100644 --- a/stack-8.6.4.yaml +++ b/stack-8.6.4.yaml @@ -18,8 +18,8 @@ extra-deps: - cabal-plan-0.6.2.0 - clock-0.7.2 - extra-1.7.3 -- floskell-0.10.3 -- fourmolu-0.1.0.0 +- floskell-0.10.4 +- fourmolu-0.1.0.0@rev:1 - fuzzy-0.1.0.0 # - ghcide-0.1.0 - ghc-check-0.5.0.1 @@ -32,7 +32,7 @@ extra-deps: - haskell-lsp-types-0.22.0.0 - hie-bios-0.6.1 - HsYAML-0.2.1.0@rev:1 -- HsYAML-aeson-0.2.0.0@rev:1 +- HsYAML-aeson-0.2.0.0@rev:2 - indexed-profunctors-0.1 - lens-4.18 - lsp-test-0.11.0.3 @@ -49,7 +49,7 @@ extra-deps: - semialign-1.1 # - github: wz1000/shake # commit: fb3859dca2e54d1bbb2c873e68ed225fa179fbef -- stylish-haskell-0.11.0.0 +- stylish-haskell-0.11.0.3 - tasty-rerun-1.1.17 - temporary-1.2.1.1 - type-equality-1 @@ -67,5 +67,3 @@ nix: packages: [ icu libcxx zlib ] concurrent-tests: false - -allow-newer: true diff --git a/stack-8.6.5.yaml b/stack-8.6.5.yaml index 88dc294e97..a5e3d128a6 100644 --- a/stack-8.6.5.yaml +++ b/stack-8.6.5.yaml @@ -17,8 +17,8 @@ extra-deps: - cabal-plan-0.6.2.0 - clock-0.7.2 - extra-1.7.3 -- floskell-0.10.3 -- fourmolu-0.1.0.0 +- floskell-0.10.4 +- fourmolu-0.1.0.0@rev:1 - fuzzy-0.1.0.0 # - ghcide-0.1.0 - ghc-check-0.5.0.1 @@ -31,7 +31,7 @@ extra-deps: - haskell-lsp-types-0.22.0.0 - hie-bios-0.6.1 - HsYAML-0.2.1.0@rev:1 -- HsYAML-aeson-0.2.0.0@rev:1 +- HsYAML-aeson-0.2.0.0@rev:2 - indexed-profunctors-0.1 - lens-4.18 - lsp-test-0.11.0.3 @@ -48,7 +48,7 @@ extra-deps: - semialign-1.1 # - github: wz1000/shake # commit: fb3859dca2e54d1bbb2c873e68ed225fa179fbef -- stylish-haskell-0.11.0.0 +- stylish-haskell-0.11.0.3 - tasty-rerun-1.1.17 - temporary-1.2.1.1 - type-equality-1 @@ -66,5 +66,3 @@ nix: packages: [ icu libcxx zlib ] concurrent-tests: false - -allow-newer: true diff --git a/stack-8.8.2.yaml b/stack-8.8.2.yaml index a1576ee984..fc357948c3 100644 --- a/stack-8.8.2.yaml +++ b/stack-8.8.2.yaml @@ -16,8 +16,8 @@ extra-deps: - clock-0.7.2 - constrained-dynamic-0.1.0.0 - extra-1.7.3 -- floskell-0.10.3 -- fourmolu-0.1.0.0 +- floskell-0.10.4 +- fourmolu-0.1.0.0@rev:1 # - ghcide-0.1.0 - ghc-check-0.5.0.1 - ghc-lib-parser-8.10.1.20200523 @@ -31,7 +31,7 @@ extra-deps: - hoogle-5.0.17.11 - hsimport-0.11.0 - HsYAML-0.2.1.0@rev:1 -- HsYAML-aeson-0.2.0.0@rev:1 +- HsYAML-aeson-0.2.0.0@rev:2 - ilist-0.3.1.0 - lsp-test-0.11.0.3 - monad-dijkstra-0.1.1.2 @@ -41,7 +41,7 @@ extra-deps: - semigroups-0.18.5 # - github: wz1000/shake # commit: fb3859dca2e54d1bbb2c873e68ed225fa179fbef -- stylish-haskell-0.11.0.0 +- stylish-haskell-0.11.0.3 - temporary-1.2.1.1 flags: @@ -56,5 +56,3 @@ nix: packages: [ icu libcxx zlib ] concurrent-tests: false - -allow-newer: true diff --git a/stack-8.8.3.yaml b/stack-8.8.3.yaml index 58afb25990..2fbfd09640 100644 --- a/stack-8.8.3.yaml +++ b/stack-8.8.3.yaml @@ -15,12 +15,13 @@ extra-deps: - clock-0.7.2 - constrained-dynamic-0.1.0.0 - extra-1.7.3 -- floskell-0.10.3 -- fourmolu-0.1.0.0 +- floskell-0.10.4 +- fourmolu-0.1.0.0@rev:1 # - ghcide-0.1.0 - haskell-src-exts-1.21.1 - hie-bios-0.6.1 - hlint-2.2.8 +- HsYAML-aeson-0.2.0.0@rev:2 - hoogle-5.0.17.11 - hsimport-0.11.0 - ilist-0.3.1.0 @@ -30,6 +31,7 @@ extra-deps: - semigroups-0.18.5 # - github: wz1000/shake # commit: fb3859dca2e54d1bbb2c873e68ed225fa179fbef +- stylish-haskell-0.11.0.3 - temporary-1.2.1.1 flags: @@ -44,5 +46,3 @@ nix: packages: [ icu libcxx zlib ] concurrent-tests: false - -allow-newer: true diff --git a/stack-8.8.4.yaml b/stack-8.8.4.yaml index c51ce84586..17133b2f64 100644 --- a/stack-8.8.4.yaml +++ b/stack-8.8.4.yaml @@ -17,12 +17,13 @@ extra-deps: - clock-0.7.2 - constrained-dynamic-0.1.0.0 - extra-1.7.3 -- floskell-0.10.3 -- fourmolu-0.1.0.0 +- floskell-0.10.4 +- fourmolu-0.1.0.0@rev:1 # - ghcide-0.1.0 - haskell-src-exts-1.21.1 - hie-bios-0.6.1 - hlint-2.2.8 +- HsYAML-aeson-0.2.0.0@rev:2 - hoogle-5.0.17.11 - hsimport-0.11.0 - ilist-0.3.1.0 @@ -30,6 +31,7 @@ extra-deps: - monad-dijkstra-0.1.1.2 - retrie-0.1.1.1 - semigroups-0.18.5 +- stylish-haskell-0.11.0.3 # - github: wz1000/shake # commit: fb3859dca2e54d1bbb2c873e68ed225fa179fbef - temporary-1.2.1.1 @@ -46,5 +48,3 @@ nix: packages: [ icu libcxx zlib ] concurrent-tests: false - -allow-newer: true diff --git a/stack.yaml b/stack.yaml index 74680e5e76..d0c745c40a 100644 --- a/stack.yaml +++ b/stack.yaml @@ -17,7 +17,8 @@ extra-deps: - cabal-plan-0.6.2.0 - clock-0.7.2 - extra-1.7.3 -- floskell-0.10.3 +- floskell-0.10.4 +- fourmolu-0.1.0.0@rev:1 - fuzzy-0.1.0.0 # - ghcide-0.1.0 - ghc-check-0.5.0.1 @@ -30,7 +31,7 @@ extra-deps: - haskell-lsp-types-0.22.0.0 - hie-bios-0.6.1 - HsYAML-0.2.1.0@rev:1 -- HsYAML-aeson-0.2.0.0@rev:1 +- HsYAML-aeson-0.2.0.0@rev:2 - indexed-profunctors-0.1 - lens-4.18 - lsp-test-0.11.0.3 @@ -45,7 +46,7 @@ extra-deps: - regex-tdfa-1.3.1.0 - retrie-0.1.1.1 - semialign-1.1 -- stylish-haskell-0.11.0.0 +- stylish-haskell-0.11.0.3 - tasty-rerun-1.1.17 - temporary-1.2.1.1 - type-equality-1 @@ -63,5 +64,3 @@ nix: packages: [ icu libcxx zlib ] concurrent-tests: false - -allow-newer: true From 6aab3fb51557447d8cee486bf8f1382b6b5fe17c Mon Sep 17 00:00:00 2001 From: George Thomas Date: Thu, 6 Aug 2020 17:07:51 +0100 Subject: [PATCH 07/14] Add fourmolu to shell.nix --- shell.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/shell.nix b/shell.nix index 7f0ffcc9be..076161c96f 100644 --- a/shell.nix +++ b/shell.nix @@ -42,6 +42,7 @@ let defaultCompiler = "ghc" + lib.replaceStrings ["."] [""] haskellPackages.ghc. data-default-instances-old-locale extra floskell + fourmolu fuzzy generic-deriving ghc-check From ca111c420b9aeb1030c0e2933b2d60578b0a5ca2 Mon Sep 17 00:00:00 2001 From: George Thomas Date: Thu, 6 Aug 2020 17:08:25 +0100 Subject: [PATCH 08/14] Vendor brittany via Github --- cabal.project | 5 +++++ stack-8.10.1.yaml | 2 ++ stack-8.6.4.yaml | 3 ++- stack-8.6.5.yaml | 3 ++- stack-8.8.2.yaml | 3 ++- stack-8.8.3.yaml | 2 ++ stack-8.8.4.yaml | 2 ++ stack.yaml | 3 ++- 8 files changed, 19 insertions(+), 4 deletions(-) diff --git a/cabal.project b/cabal.project index 2618181aa4..59b44cc269 100644 --- a/cabal.project +++ b/cabal.project @@ -2,6 +2,11 @@ packages: ./ ghcide +source-repository-package + type: git + location: https://github.com/lspitzner/brittany.git + tag: 7d68b1cc3809e2921756c3a1bf67a83e82c21b0a + tests: true package * diff --git a/stack-8.10.1.yaml b/stack-8.10.1.yaml index 52fbc08dc3..d8f945deb4 100644 --- a/stack-8.10.1.yaml +++ b/stack-8.10.1.yaml @@ -9,6 +9,8 @@ ghc-options: extra-deps: - aeson-1.5.2.0 +- github: lspitzner/brittany + commit: 7d68b1cc3809e2921756c3a1bf67a83e82c21b0a - Cabal-3.0.2.0 - hie-bios-0.6.1 - cabal-plan-0.7.0.0 diff --git a/stack-8.6.4.yaml b/stack-8.6.4.yaml index e5ce663d95..1dafbadbe8 100644 --- a/stack-8.6.4.yaml +++ b/stack-8.6.4.yaml @@ -12,7 +12,8 @@ extra-deps: - aeson-1.5.2.0 - ansi-terminal-0.10.3 - base-compat-0.11.0 -- brittany-0.12.1.1@rev:2 +- github: lspitzner/brittany + commit: 7d68b1cc3809e2921756c3a1bf67a83e82c21b0a - butcher-1.3.3.1 - Cabal-3.0.2.0 - cabal-plan-0.6.2.0 diff --git a/stack-8.6.5.yaml b/stack-8.6.5.yaml index a5e3d128a6..edf57d681c 100644 --- a/stack-8.6.5.yaml +++ b/stack-8.6.5.yaml @@ -11,7 +11,8 @@ extra-deps: - aeson-1.5.2.0 - ansi-terminal-0.10.3 - base-compat-0.11.0 -- brittany-0.12.1.1@rev:2 +- github: lspitzner/brittany + commit: 7d68b1cc3809e2921756c3a1bf67a83e82c21b0a - butcher-1.3.3.1 - Cabal-3.0.2.0 - cabal-plan-0.6.2.0 diff --git a/stack-8.8.2.yaml b/stack-8.8.2.yaml index fc357948c3..22481675e2 100644 --- a/stack-8.8.2.yaml +++ b/stack-8.8.2.yaml @@ -10,7 +10,8 @@ ghc-options: extra-deps: - aeson-1.5.2.0 - apply-refact-0.7.0.0 -- brittany-0.12.1.1 +- github: lspitzner/brittany + commit: 7d68b1cc3809e2921756c3a1bf67a83e82c21b0a - butcher-1.3.3.2 - bytestring-trie-0.2.5.0 - clock-0.7.2 diff --git a/stack-8.8.3.yaml b/stack-8.8.3.yaml index 2fbfd09640..c3e98b6910 100644 --- a/stack-8.8.3.yaml +++ b/stack-8.8.3.yaml @@ -10,6 +10,8 @@ ghc-options: extra-deps: - aeson-1.5.2.0 - apply-refact-0.7.0.0 +- github: lspitzner/brittany + commit: 7d68b1cc3809e2921756c3a1bf67a83e82c21b0a - bytestring-trie-0.2.5.0 - cabal-plan-0.6.2.0 - clock-0.7.2 diff --git a/stack-8.8.4.yaml b/stack-8.8.4.yaml index 17133b2f64..6ac0a7494d 100644 --- a/stack-8.8.4.yaml +++ b/stack-8.8.4.yaml @@ -11,6 +11,8 @@ ghc-options: extra-deps: - aeson-1.5.2.0 - apply-refact-0.7.0.0 +- github: lspitzner/brittany + commit: 7d68b1cc3809e2921756c3a1bf67a83e82c21b0a - bytestring-trie-0.2.5.0 - cabal-helper-1.1.0.0 - cabal-plan-0.6.2.0 diff --git a/stack.yaml b/stack.yaml index d0c745c40a..b83bca297b 100644 --- a/stack.yaml +++ b/stack.yaml @@ -11,7 +11,8 @@ extra-deps: - aeson-1.5.2.0 - ansi-terminal-0.10.3 - base-compat-0.11.0 -- brittany-0.12.1.1@rev:2 +- github: lspitzner/brittany + commit: 7d68b1cc3809e2921756c3a1bf67a83e82c21b0a - butcher-1.3.3.1 - Cabal-3.0.2.0 - cabal-plan-0.6.2.0 From ceb92b94342e7f6ca443186f61516e5fc93b5bf8 Mon Sep 17 00:00:00 2001 From: Luke Lau Date: Thu, 6 Aug 2020 19:04:15 +0100 Subject: [PATCH 09/14] Use vendored Brittany which builds on ghc-8.10.1 --- cabal.project | 8 +++++--- stack-8.10.1.yaml | 8 ++------ stack-8.6.4.yaml | 4 ++-- stack-8.6.5.yaml | 4 ++-- stack-8.8.2.yaml | 4 ++-- stack-8.8.3.yaml | 4 ++-- stack-8.8.4.yaml | 4 ++-- stack.yaml | 4 ++-- 8 files changed, 19 insertions(+), 21 deletions(-) diff --git a/cabal.project b/cabal.project index 59b44cc269..d3f1e51fe0 100644 --- a/cabal.project +++ b/cabal.project @@ -4,8 +4,8 @@ packages: source-repository-package type: git - location: https://github.com/lspitzner/brittany.git - tag: 7d68b1cc3809e2921756c3a1bf67a83e82c21b0a + location: https://github.com/bubba/brittany.git + tag: c59655f10d5ad295c2481537fc8abf0a297d9d1c tests: true @@ -19,4 +19,6 @@ package ghcide write-ghc-environment-files: never -index-state: 2020-08-05T14:24:10Z +index-state: 2020-08-06T16:54:56Z + +allow-newer: data-tree-print:base diff --git a/stack-8.10.1.yaml b/stack-8.10.1.yaml index d8f945deb4..de33b9569b 100644 --- a/stack-8.10.1.yaml +++ b/stack-8.10.1.yaml @@ -9,8 +9,8 @@ ghc-options: extra-deps: - aeson-1.5.2.0 -- github: lspitzner/brittany - commit: 7d68b1cc3809e2921756c3a1bf67a83e82c21b0a +- github: bubba/brittany + commit: c59655f10d5ad295c2481537fc8abf0a297d9d1c - Cabal-3.0.2.0 - hie-bios-0.6.1 - cabal-plan-0.7.0.0 @@ -33,10 +33,6 @@ extra-deps: flags: haskell-language-server: pedantic: true - # We want to let agpl be the default value in .cabal (True) - # but brittany is not usable with ghc-8.10.1 - # see https://github.com/lspitzner/brittany/issues/269 - agpl: false retrie: BuildExecutable: false diff --git a/stack-8.6.4.yaml b/stack-8.6.4.yaml index 1dafbadbe8..111fd01f5d 100644 --- a/stack-8.6.4.yaml +++ b/stack-8.6.4.yaml @@ -12,8 +12,8 @@ extra-deps: - aeson-1.5.2.0 - ansi-terminal-0.10.3 - base-compat-0.11.0 -- github: lspitzner/brittany - commit: 7d68b1cc3809e2921756c3a1bf67a83e82c21b0a +- github: bubba/brittany + commit: c59655f10d5ad295c2481537fc8abf0a297d9d1c - butcher-1.3.3.1 - Cabal-3.0.2.0 - cabal-plan-0.6.2.0 diff --git a/stack-8.6.5.yaml b/stack-8.6.5.yaml index edf57d681c..b9689d59b9 100644 --- a/stack-8.6.5.yaml +++ b/stack-8.6.5.yaml @@ -11,8 +11,8 @@ extra-deps: - aeson-1.5.2.0 - ansi-terminal-0.10.3 - base-compat-0.11.0 -- github: lspitzner/brittany - commit: 7d68b1cc3809e2921756c3a1bf67a83e82c21b0a +- github: bubba/brittany + commit: c59655f10d5ad295c2481537fc8abf0a297d9d1c - butcher-1.3.3.1 - Cabal-3.0.2.0 - cabal-plan-0.6.2.0 diff --git a/stack-8.8.2.yaml b/stack-8.8.2.yaml index 22481675e2..25b03c8f24 100644 --- a/stack-8.8.2.yaml +++ b/stack-8.8.2.yaml @@ -10,8 +10,8 @@ ghc-options: extra-deps: - aeson-1.5.2.0 - apply-refact-0.7.0.0 -- github: lspitzner/brittany - commit: 7d68b1cc3809e2921756c3a1bf67a83e82c21b0a +- github: bubba/brittany + commit: c59655f10d5ad295c2481537fc8abf0a297d9d1c - butcher-1.3.3.2 - bytestring-trie-0.2.5.0 - clock-0.7.2 diff --git a/stack-8.8.3.yaml b/stack-8.8.3.yaml index c3e98b6910..2c9014352a 100644 --- a/stack-8.8.3.yaml +++ b/stack-8.8.3.yaml @@ -10,8 +10,8 @@ ghc-options: extra-deps: - aeson-1.5.2.0 - apply-refact-0.7.0.0 -- github: lspitzner/brittany - commit: 7d68b1cc3809e2921756c3a1bf67a83e82c21b0a +- github: bubba/brittany + commit: c59655f10d5ad295c2481537fc8abf0a297d9d1c - bytestring-trie-0.2.5.0 - cabal-plan-0.6.2.0 - clock-0.7.2 diff --git a/stack-8.8.4.yaml b/stack-8.8.4.yaml index 6ac0a7494d..c10b6b7872 100644 --- a/stack-8.8.4.yaml +++ b/stack-8.8.4.yaml @@ -11,8 +11,8 @@ ghc-options: extra-deps: - aeson-1.5.2.0 - apply-refact-0.7.0.0 -- github: lspitzner/brittany - commit: 7d68b1cc3809e2921756c3a1bf67a83e82c21b0a +- github: bubba/brittany + commit: c59655f10d5ad295c2481537fc8abf0a297d9d1c - bytestring-trie-0.2.5.0 - cabal-helper-1.1.0.0 - cabal-plan-0.6.2.0 diff --git a/stack.yaml b/stack.yaml index b83bca297b..b21869734c 100644 --- a/stack.yaml +++ b/stack.yaml @@ -11,8 +11,8 @@ extra-deps: - aeson-1.5.2.0 - ansi-terminal-0.10.3 - base-compat-0.11.0 -- github: lspitzner/brittany - commit: 7d68b1cc3809e2921756c3a1bf67a83e82c21b0a +- github: bubba/brittany + commit: c59655f10d5ad295c2481537fc8abf0a297d9d1c - butcher-1.3.3.1 - Cabal-3.0.2.0 - cabal-plan-0.6.2.0 From 155c01d0f2a9d98d3e0ca23c6c2380eae08fc2b3 Mon Sep 17 00:00:00 2001 From: Luke Lau Date: Thu, 6 Aug 2020 20:48:58 +0100 Subject: [PATCH 10/14] Fix 8.6.x extra-deps in stack --- stack-8.6.4.yaml | 4 +++- stack-8.6.5.yaml | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/stack-8.6.4.yaml b/stack-8.6.4.yaml index 111fd01f5d..c500bf731e 100644 --- a/stack-8.6.4.yaml +++ b/stack-8.6.4.yaml @@ -11,7 +11,7 @@ ghc-options: extra-deps: - aeson-1.5.2.0 - ansi-terminal-0.10.3 -- base-compat-0.11.0 +- base-compat-0.10.5 - github: bubba/brittany commit: c59655f10d5ad295c2481537fc8abf0a297d9d1c - butcher-1.3.3.1 @@ -43,6 +43,7 @@ extra-deps: - optparse-applicative-0.15.1.0 - ormolu-0.1.2.0 - parser-combinators-1.2.1 +- primitive-0.7.1.0 - regex-base-0.94.0.0 - regex-pcre-builtin-0.95.1.1.8.43 - regex-tdfa-1.3.1.0 @@ -53,6 +54,7 @@ extra-deps: - stylish-haskell-0.11.0.3 - tasty-rerun-1.1.17 - temporary-1.2.1.1 +- these-1.1.1.1 - type-equality-1 - topograph-1 diff --git a/stack-8.6.5.yaml b/stack-8.6.5.yaml index b9689d59b9..08d1ea7128 100644 --- a/stack-8.6.5.yaml +++ b/stack-8.6.5.yaml @@ -10,7 +10,7 @@ ghc-options: extra-deps: - aeson-1.5.2.0 - ansi-terminal-0.10.3 -- base-compat-0.11.0 +- base-compat-0.10.5 - github: bubba/brittany commit: c59655f10d5ad295c2481537fc8abf0a297d9d1c - butcher-1.3.3.1 @@ -42,6 +42,7 @@ extra-deps: - optparse-applicative-0.15.1.0 - ormolu-0.1.2.0 - parser-combinators-1.2.1 +- primitive-0.7.1.0 - regex-base-0.94.0.0 - regex-pcre-builtin-0.95.1.1.8.43 - regex-tdfa-1.3.1.0 @@ -52,6 +53,7 @@ extra-deps: - stylish-haskell-0.11.0.3 - tasty-rerun-1.1.17 - temporary-1.2.1.1 +- these-1.1.1.1 - type-equality-1 - topograph-1 From 0cca5dba00c658776b9b5850ac7e1f3843c98541 Mon Sep 17 00:00:00 2001 From: Luke Lau Date: Thu, 6 Aug 2020 21:04:51 +0100 Subject: [PATCH 11/14] Add Brittany to ghc-8.10.1 --- exe/Main.hs | 4 +--- haskell-language-server.cabal | 9 ++++----- test/functional/Format.hs | 17 +++++------------ test/testdata/Format.brittany.formatted.hs | 5 ++++- .../Format.brittany_post_floskell.formatted.hs | 5 ++++- 5 files changed, 18 insertions(+), 22 deletions(-) diff --git a/exe/Main.hs b/exe/Main.hs index 612d6e77eb..725a752b95 100644 --- a/exe/Main.hs +++ b/exe/Main.hs @@ -71,7 +71,7 @@ import Ide.Plugin.Fourmolu as Fourmolu import Ide.Plugin.Ormolu as Ormolu import Ide.Plugin.StylishHaskell as StylishHaskell import Ide.Plugin.Retrie as Retrie -#if AGPL && !MIN_VERSION_ghc(8,10,1) +#if AGPL import Ide.Plugin.Brittany as Brittany #endif import Ide.Plugin.Pragmas as Pragmas @@ -110,9 +110,7 @@ idePlugins includeExamples = pluginDescToIdePlugins allPlugins , StylishHaskell.descriptor "stylish-haskell" , Retrie.descriptor "retrie" #if AGPL -#if !MIN_VERSION_ghc(8,10,1) , Brittany.descriptor "brittany" -#endif #endif , Eval.descriptor "eval" ] diff --git a/haskell-language-server.cabal b/haskell-language-server.cabal index 266b266dc4..404b1c5f1e 100644 --- a/haskell-language-server.cabal +++ b/haskell-language-server.cabal @@ -103,11 +103,10 @@ library else build-depends: unix if flag(agpl) - if impl(ghc < 8.10) - build-depends: - brittany - exposed-modules: - Ide.Plugin.Brittany + build-depends: + brittany + exposed-modules: + Ide.Plugin.Brittany ghc-options: -Wall diff --git a/test/functional/Format.hs b/test/functional/Format.hs index 0ebac31071..0bb2ee4944 100644 --- a/test/functional/Format.hs +++ b/test/functional/Format.hs @@ -12,8 +12,7 @@ import Test.Tasty import Test.Tasty.Golden import Test.Tasty.HUnit -#if MIN_VERSION_GLASGOW_HASKELL(8,10,0,0) || !defined(AGPL) -#else +#if AGPL import qualified Data.Text.IO as T #endif @@ -30,9 +29,7 @@ tests = testGroup "format document" [ , rangeTests , providerTests , stylishHaskellTests --- There's no Brittany formatter on the 8.10.1 builds (yet) -#if MIN_VERSION_GLASGOW_HASKELL(8,10,0,0) || !defined(AGPL) -#else +#if AGPL , brittanyTests #endif , ormoluTests @@ -63,9 +60,7 @@ providerTests = testGroup "formatting provider" [ formatRange doc (FormattingOptions 2 True) (Range (Position 1 0) (Position 3 10)) documentContents doc >>= liftIO . (@?= orig) --- There's no Brittany formatter on the 8.10.1 builds (yet) -#if MIN_VERSION_GLASGOW_HASKELL(8,10,0,0) || !defined(AGPL) -#else +#if AGPL , testCase "can change on the fly" $ runSession hieCommand fullCaps "test/testdata" $ do formattedBrittany <- liftIO $ T.readFile "test/testdata/Format.brittany.formatted.hs" formattedFloskell <- liftIO $ T.readFile "test/testdata/Format.floskell.formatted.hs" @@ -114,8 +109,7 @@ stylishHaskellTests = testGroup "stylish-haskell" [ BS.fromStrict . T.encodeUtf8 <$> documentContents doc ] -#if MIN_VERSION_GLASGOW_HASKELL(8,10,0,0) || !defined(AGPL) -#else +#if AGPL brittanyTests :: TestTree brittanyTests = testGroup "brittany" [ goldenVsStringDiff "formats a document with LF endings" goldenGitDiff "test/testdata/BrittanyLF.formatted_document.hs" $ runSession hieCommand fullCaps "test/testdata" $ do @@ -177,8 +171,7 @@ fourmoluTests = testGroup "fourmolu" formatLspConfig :: Value -> Value formatLspConfig provider = object [ "haskell" .= object ["formattingProvider" .= (provider :: Value)] ] -#if MIN_VERSION_GLASGOW_HASKELL(8,10,0,0) || !defined(AGPL) -#else +#if AGPL -- | The same as 'formatLspConfig' but using the legacy section name formatLspConfigOld :: Value -> Value formatLspConfigOld provider = object [ "languageServerHaskell" .= object ["formattingProvider" .= (provider :: Value)] ] diff --git a/test/testdata/Format.brittany.formatted.hs b/test/testdata/Format.brittany.formatted.hs index d3da590142..9ecc458524 100644 --- a/test/testdata/Format.brittany.formatted.hs +++ b/test/testdata/Format.brittany.formatted.hs @@ -11,5 +11,8 @@ bar s = do x <- return "hello" return "asdf" -data Baz = Baz { a :: Int, b :: String } +data Baz = Baz + { a :: Int + , b :: String + } diff --git a/test/testdata/Format.brittany_post_floskell.formatted.hs b/test/testdata/Format.brittany_post_floskell.formatted.hs index 02de9c673d..9cbb33715c 100644 --- a/test/testdata/Format.brittany_post_floskell.formatted.hs +++ b/test/testdata/Format.brittany_post_floskell.formatted.hs @@ -13,5 +13,8 @@ bar s = do x <- return "hello" return "asdf" -data Baz = Baz { a :: Int, b :: String } +data Baz = Baz + { a :: Int + , b :: String + } From 0206b7d2f3e04c9ff4e699a1366626522b352df3 Mon Sep 17 00:00:00 2001 From: Luke Lau Date: Thu, 6 Aug 2020 21:18:13 +0100 Subject: [PATCH 12/14] Fix stack 8.8.2 build --- stack-8.8.2.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/stack-8.8.2.yaml b/stack-8.8.2.yaml index 25b03c8f24..29e365a7b9 100644 --- a/stack-8.8.2.yaml +++ b/stack-8.8.2.yaml @@ -44,6 +44,7 @@ extra-deps: # commit: fb3859dca2e54d1bbb2c873e68ed225fa179fbef - stylish-haskell-0.11.0.3 - temporary-1.2.1.1 +- these-1.1.1.1 flags: haskell-language-server: From f291879d17297314d2954cbe2aa55f968b64c660 Mon Sep 17 00:00:00 2001 From: Luke Lau Date: Thu, 6 Aug 2020 21:55:38 +0100 Subject: [PATCH 13/14] Fix stack 8.10.1 build --- stack-8.10.1.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/stack-8.10.1.yaml b/stack-8.10.1.yaml index de33b9569b..0cd13c46f9 100644 --- a/stack-8.10.1.yaml +++ b/stack-8.10.1.yaml @@ -15,6 +15,7 @@ extra-deps: - hie-bios-0.6.1 - cabal-plan-0.7.0.0 - clock-0.7.2 +- data-tree-print-0.1.0.2 - floskell-0.10.4 - fourmolu-0.1.0.0@rev:1 - ghc-exactprint-0.6.3 @@ -36,7 +37,8 @@ flags: retrie: BuildExecutable: false -# allow-newer: true +# for data-tree-print's bounds on base (>=4.8 && <4.14); using base-4.14.0.0. +allow-newer: true nix: packages: [ icu libcxx zlib ] From 3df2bbc70442d9960d2b2dde3ec69320da7c0ba5 Mon Sep 17 00:00:00 2001 From: Luke Lau Date: Fri, 7 Aug 2020 12:52:39 +0100 Subject: [PATCH 14/14] Update lsp-test to 0.11.0.4 Fixes bug with document versions in testing --- cabal.project | 2 +- haskell-language-server.cabal | 4 ++-- stack-8.10.1.yaml | 2 +- stack-8.6.4.yaml | 2 +- stack-8.6.5.yaml | 2 +- stack-8.8.2.yaml | 2 +- stack-8.8.3.yaml | 2 +- stack-8.8.4.yaml | 2 +- stack.yaml | 2 +- 9 files changed, 10 insertions(+), 10 deletions(-) diff --git a/cabal.project b/cabal.project index d3f1e51fe0..5ad04de72b 100644 --- a/cabal.project +++ b/cabal.project @@ -19,6 +19,6 @@ package ghcide write-ghc-environment-files: never -index-state: 2020-08-06T16:54:56Z +index-state: 2020-08-07T11:45:57Z allow-newer: data-tree-print:base diff --git a/haskell-language-server.cabal b/haskell-language-server.cabal index 404b1c5f1e..488b6b684b 100644 --- a/haskell-language-server.cabal +++ b/haskell-language-server.cabal @@ -224,7 +224,7 @@ common hls-test-utils , hslogger , hspec , hspec-core - , lsp-test >= 0.11.0.3 + , lsp-test >= 0.11.0.4 , stm , tasty-hunit , temporary @@ -253,7 +253,7 @@ test-suite func-test , haskell-lsp , haskell-lsp-types , lens - , lsp-test >= 0.11.0.3 + , lsp-test >= 0.11.0.4 , tasty , tasty-ant-xml >= 1.1.6 , tasty-expected-failure diff --git a/stack-8.10.1.yaml b/stack-8.10.1.yaml index 0cd13c46f9..f1494f4265 100644 --- a/stack-8.10.1.yaml +++ b/stack-8.10.1.yaml @@ -21,7 +21,7 @@ extra-deps: - ghc-exactprint-0.6.3 - HsYAML-aeson-0.2.0.0@rev:2 - lens-4.19.1 -- lsp-test-0.11.0.3 +- lsp-test-0.11.0.4 - monad-dijkstra-0.1.1.2 - optics-core-0.3 - ormolu-0.1.2.0 diff --git a/stack-8.6.4.yaml b/stack-8.6.4.yaml index c500bf731e..896254b08e 100644 --- a/stack-8.6.4.yaml +++ b/stack-8.6.4.yaml @@ -36,7 +36,7 @@ extra-deps: - HsYAML-aeson-0.2.0.0@rev:2 - indexed-profunctors-0.1 - lens-4.18 -- lsp-test-0.11.0.3 +- lsp-test-0.11.0.4 - monad-dijkstra-0.1.1.2 - opentelemetry-0.4.2 - optics-core-0.2 diff --git a/stack-8.6.5.yaml b/stack-8.6.5.yaml index 08d1ea7128..605591b432 100644 --- a/stack-8.6.5.yaml +++ b/stack-8.6.5.yaml @@ -35,7 +35,7 @@ extra-deps: - HsYAML-aeson-0.2.0.0@rev:2 - indexed-profunctors-0.1 - lens-4.18 -- lsp-test-0.11.0.3 +- lsp-test-0.11.0.4 - monad-dijkstra-0.1.1.2 - opentelemetry-0.4.2 - optics-core-0.2 diff --git a/stack-8.8.2.yaml b/stack-8.8.2.yaml index 29e365a7b9..131969fa4c 100644 --- a/stack-8.8.2.yaml +++ b/stack-8.8.2.yaml @@ -34,7 +34,7 @@ extra-deps: - HsYAML-0.2.1.0@rev:1 - HsYAML-aeson-0.2.0.0@rev:2 - ilist-0.3.1.0 -- lsp-test-0.11.0.3 +- lsp-test-0.11.0.4 - monad-dijkstra-0.1.1.2 - opentelemetry-0.4.2 - ormolu-0.1.2.0 diff --git a/stack-8.8.3.yaml b/stack-8.8.3.yaml index 2c9014352a..c52d3afe2a 100644 --- a/stack-8.8.3.yaml +++ b/stack-8.8.3.yaml @@ -27,7 +27,7 @@ extra-deps: - hoogle-5.0.17.11 - hsimport-0.11.0 - ilist-0.3.1.0 -- lsp-test-0.11.0.3 +- lsp-test-0.11.0.4 - monad-dijkstra-0.1.1.2 - retrie-0.1.1.1 - semigroups-0.18.5 diff --git a/stack-8.8.4.yaml b/stack-8.8.4.yaml index c10b6b7872..08ce987d48 100644 --- a/stack-8.8.4.yaml +++ b/stack-8.8.4.yaml @@ -29,7 +29,7 @@ extra-deps: - hoogle-5.0.17.11 - hsimport-0.11.0 - ilist-0.3.1.0 -- lsp-test-0.11.0.3 +- lsp-test-0.11.0.4 - monad-dijkstra-0.1.1.2 - retrie-0.1.1.1 - semigroups-0.18.5 diff --git a/stack.yaml b/stack.yaml index b21869734c..2350fff2d5 100644 --- a/stack.yaml +++ b/stack.yaml @@ -35,7 +35,7 @@ extra-deps: - HsYAML-aeson-0.2.0.0@rev:2 - indexed-profunctors-0.1 - lens-4.18 -- lsp-test-0.11.0.3 +- lsp-test-0.11.0.4 - monad-dijkstra-0.1.1.2 - opentelemetry-0.4.2 - optics-core-0.2