Skip to content

Commit d95ea23

Browse files
committed
Drop support for pre-0.7 versions of the Fourmolu library
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.
1 parent 3d9f9a2 commit d95ea23

File tree

2 files changed

+3
-23
lines changed

2 files changed

+3
-23
lines changed

plugins/hls-fourmolu-plugin/hls-fourmolu-plugin.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ library
2929
build-depends:
3030
, base >=4.12 && <5
3131
, filepath
32-
, fourmolu ^>=0.3 || ^>=0.4 || ^>= 0.6 || ^>= 0.7
32+
, fourmolu ^>= 0.7
3333
, ghc
3434
, ghc-boot-th
3535
, ghcide ^>=1.7

plugins/hls-fourmolu-plugin/src/Ide/Plugin/Fourmolu.hs

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
{-# LANGUAGE CPP #-}
21
{-# LANGUAGE DataKinds #-}
32
{-# LANGUAGE DisambiguateRecordFields #-}
43
{-# LANGUAGE LambdaCase #-}
@@ -85,13 +84,7 @@ provider plId ideState typ contents fp fo = withIndefiniteProgress title Cancell
8584
first (mkError . show)
8685
<$> try @OrmoluException (makeDiffTextEdit contents <$> ormolu config fp' (T.unpack contents))
8786
where
88-
printerOpts =
89-
#if MIN_VERSION_fourmolu(0,7,0)
90-
cfgFilePrinterOpts fourmoluConfig
91-
#else
92-
fourmoluConfig
93-
94-
#endif
87+
printerOpts = cfgFilePrinterOpts fourmoluConfig
9588
config =
9689
defaultConfig
9790
{ cfgDynOptions = map DynOption fileOpts
@@ -101,10 +94,8 @@ provider plId ideState typ contents fp fo = withIndefiniteProgress title Cancell
10194
fillMissingPrinterOpts
10295
(printerOpts <> lspPrinterOpts)
10396
defaultPrinterOpts
104-
#if MIN_VERSION_fourmolu(0,7,0)
10597
, cfgFixityOverrides =
10698
cfgFileFixities fourmoluConfig
107-
#endif
10899
}
109100
in liftIO (loadConfigFile fp') >>= \case
110101
ConfigLoaded file opts -> liftIO $ do
@@ -118,15 +109,10 @@ provider plId ideState typ contents fp fo = withIndefiniteProgress title Cancell
118109
format emptyOptions
119110
where
120111
emptyOptions =
121-
#if MIN_VERSION_fourmolu(0,7,0)
122112
FourmoluConfig
123113
{ cfgFilePrinterOpts = mempty
124114
, cfgFileFixities = mempty
125115
}
126-
#else
127-
mempty
128-
#endif
129-
130116
ConfigParseError f err -> do
131117
sendNotification SWindowShowMessage $
132118
ShowMessageParams
@@ -135,13 +121,7 @@ provider plId ideState typ contents fp fo = withIndefiniteProgress title Cancell
135121
}
136122
return . Left $ responseError errorMessage
137123
where
138-
errorMessage = "Failed to load " <> T.pack f <> ": " <> T.pack (convertErr err)
139-
convertErr =
140-
#if MIN_VERSION_fourmolu(0,7,0)
141-
show
142-
#else
143-
snd
144-
#endif
124+
errorMessage = "Failed to load " <> T.pack f <> ": " <> T.pack (show err)
145125
where
146126
fp' = fromNormalizedFilePath fp
147127
title = "Formatting " <> T.pack (takeFileName fp')

0 commit comments

Comments
 (0)