Skip to content

Commit

Permalink
Drop support for pre-0.7 versions of the Fourmolu library
Browse files Browse the repository at this point in the history
Some of these have genuine bugs, as discussed in #2254 (comment). We also get to drop a load of CPP introduced in #2944.

Users can still use older versions via CLI mode.

This wasn't possible until recently because `stylish-haskell`'s `ghc-lib-parser` bounds were holding us back.
  • Loading branch information
georgefst committed Jun 12, 2022
1 parent bb6b4e1 commit 7bd219a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 23 deletions.
2 changes: 1 addition & 1 deletion plugins/hls-fourmolu-plugin/hls-fourmolu-plugin.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ library
build-depends:
, base >=4.12 && <5
, filepath
, fourmolu ^>=0.3 || ^>=0.4 || ^>= 0.6 || ^>= 0.7
, fourmolu ^>= 0.7
, ghc
, ghc-boot-th
, ghcide ^>=1.7
Expand Down
24 changes: 2 additions & 22 deletions plugins/hls-fourmolu-plugin/src/Ide/Plugin/Fourmolu.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DisambiguateRecordFields #-}
{-# LANGUAGE LambdaCase #-}
Expand Down Expand Up @@ -85,13 +84,7 @@ provider plId ideState typ contents fp fo = withIndefiniteProgress title Cancell
first (mkError . show)
<$> try @OrmoluException (makeDiffTextEdit contents <$> ormolu config fp' (T.unpack contents))
where
printerOpts =
#if MIN_VERSION_fourmolu(0,7,0)
cfgFilePrinterOpts fourmoluConfig
#else
fourmoluConfig

#endif
printerOpts = cfgFilePrinterOpts fourmoluConfig
config =
defaultConfig
{ cfgDynOptions = map DynOption fileOpts
Expand All @@ -101,10 +94,8 @@ provider plId ideState typ contents fp fo = withIndefiniteProgress title Cancell
fillMissingPrinterOpts
(printerOpts <> lspPrinterOpts)
defaultPrinterOpts
#if MIN_VERSION_fourmolu(0,7,0)
, cfgFixityOverrides =
cfgFileFixities fourmoluConfig
#endif
}
in liftIO (loadConfigFile fp') >>= \case
ConfigLoaded file opts -> liftIO $ do
Expand All @@ -118,15 +109,10 @@ provider plId ideState typ contents fp fo = withIndefiniteProgress title Cancell
format emptyOptions
where
emptyOptions =
#if MIN_VERSION_fourmolu(0,7,0)
FourmoluConfig
{ cfgFilePrinterOpts = mempty
, cfgFileFixities = mempty
}
#else
mempty
#endif

ConfigParseError f err -> do
sendNotification SWindowShowMessage $
ShowMessageParams
Expand All @@ -135,13 +121,7 @@ provider plId ideState typ contents fp fo = withIndefiniteProgress title Cancell
}
return . Left $ responseError errorMessage
where
errorMessage = "Failed to load " <> T.pack f <> ": " <> T.pack (convertErr err)
convertErr =
#if MIN_VERSION_fourmolu(0,7,0)
show
#else
snd
#endif
errorMessage = "Failed to load " <> T.pack f <> ": " <> T.pack (show err)
where
fp' = fromNormalizedFilePath fp
title = "Formatting " <> T.pack (takeFileName fp')
Expand Down

0 comments on commit 7bd219a

Please sign in to comment.