Skip to content

Commit bada830

Browse files
Use latest version of fourmolu possible (#3764)
* Remove fourmolu pin in stack.yaml * Require fourmolu >= 0.9 * Use specific versions of fourmolu for each version of GHC --------- Co-authored-by: Michael Peyton Jones <me@michaelpj.com>
1 parent 956f9b7 commit bada830

File tree

4 files changed

+12
-81
lines changed

4 files changed

+12
-81
lines changed

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

+9-2
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,11 @@ library
2626
buildable: True
2727
exposed-modules:
2828
Ide.Plugin.Fourmolu
29-
, Ide.Plugin.Fourmolu.Shim
3029
hs-source-dirs: src
3130
ghc-options: -Wall
3231
build-depends:
3332
, base >=4.12 && <5
3433
, filepath
35-
, fourmolu ^>=0.3 || ^>=0.4 || ^>= 0.6 || ^>= 0.7 || ^>= 0.8 || ^>= 0.9 || ^>= 0.10 || ^>= 0.11 || ^>= 0.12 || ^>= 0.13
3634
, ghc
3735
, ghc-boot-th
3836
, ghcide == 2.2.0.0
@@ -44,6 +42,15 @@ library
4442
, text
4543
, transformers
4644

45+
if impl(ghc >= 8.10) && impl(ghc < 9.0)
46+
build-depends: fourmolu ^>= 0.9
47+
elif impl(ghc >= 9.0) && impl(ghc < 9.2)
48+
build-depends: fourmolu ^>= 0.11
49+
elif impl(ghc >= 9.2) && impl(ghc < 9.8)
50+
build-depends: fourmolu ^>= 0.13
51+
else
52+
buildable: false
53+
4754
-- fourmolu 0.9.0 fails to build on Windows CI for reasons unknown
4855
if impl(ghc >= 9.2) && os(windows) && impl(ghc < 9.4)
4956
build-depends: fourmolu > 0.9.0.0 || < 0.9.0.0

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ import Development.IDE.GHC.Compat as Compat hiding (Cpp, Warning,
3434
import qualified Development.IDE.GHC.Compat.Util as S
3535
import GHC.LanguageExtensions.Type (Extension (Cpp))
3636
import Ide.Plugin.Error
37-
import Ide.Plugin.Fourmolu.Shim
3837
import Ide.Plugin.Properties
3938
import Ide.PluginUtils (makeDiffTextEdit)
4039
import Ide.Types
@@ -43,6 +42,7 @@ import Language.LSP.Protocol.Message
4342
import Language.LSP.Protocol.Types
4443
import Language.LSP.Server hiding (defaultConfig)
4544
import Ormolu
45+
import Ormolu.Config
4646
import System.Exit
4747
import System.FilePath
4848
import System.Process.Run (cwd, proc)
@@ -87,9 +87,9 @@ provider recorder plId ideState typ contents fp fo = ExceptT $ withIndefinitePro
8787
where
8888
printerOpts = cfgFilePrinterOpts fourmoluConfig
8989
config =
90-
addFixityOverrides (cfgFileFixities fourmoluConfig) $
9190
defaultConfig
9291
{ cfgDynOptions = map DynOption fileOpts
92+
, cfgFixityOverrides = cfgFileFixities fourmoluConfig
9393
, cfgRegion = region
9494
, cfgDebug = False
9595
, cfgPrinterOpts =
@@ -112,7 +112,7 @@ provider recorder plId ideState typ contents fp fo = ExceptT $ withIndefinitePro
112112
}
113113
throwError $ PluginInternalError errorMessage
114114
where
115-
errorMessage = "Failed to load " <> T.pack f <> ": " <> T.pack (showParseError err)
115+
errorMessage = "Failed to load " <> T.pack f <> ": " <> T.pack (show err)
116116
where
117117
fp' = fromNormalizedFilePath fp
118118
title = "Formatting " <> T.pack (takeFileName fp')

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

-75
This file was deleted.

stack.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ extra-deps:
4646
- hiedb-0.4.3.0
4747
- implicit-hie-0.1.2.7
4848
- implicit-hie-cradle-0.5.0.1
49-
- fourmolu-0.12.0.0
5049
- algebraic-graphs-0.6.1
5150
- retrie-1.2.2
5251
- hw-fingertree-0.1.2.1

0 commit comments

Comments
 (0)