Skip to content

Use latest version of fourmolu possible #3764

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Sep 6, 2023
Merged
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
11 changes: 9 additions & 2 deletions plugins/hls-fourmolu-plugin/hls-fourmolu-plugin.cabal
Original file line number Diff line number Diff line change
@@ -26,13 +26,11 @@ library
buildable: True
exposed-modules:
Ide.Plugin.Fourmolu
, Ide.Plugin.Fourmolu.Shim
hs-source-dirs: src
ghc-options: -Wall
build-depends:
, base >=4.12 && <5
, filepath
, fourmolu ^>=0.3 || ^>=0.4 || ^>= 0.6 || ^>= 0.7 || ^>= 0.8 || ^>= 0.9 || ^>= 0.10 || ^>= 0.11 || ^>= 0.12 || ^>= 0.13
, ghc
, ghc-boot-th
, ghcide == 2.2.0.0
@@ -44,6 +42,15 @@ library
, text
, transformers

if impl(ghc >= 8.10) && impl(ghc < 9.0)
build-depends: fourmolu ^>= 0.9
elif impl(ghc >= 9.0) && impl(ghc < 9.2)
build-depends: fourmolu ^>= 0.11
elif impl(ghc >= 9.2) && impl(ghc < 9.8)
build-depends: fourmolu ^>= 0.13
else
buildable: false

-- fourmolu 0.9.0 fails to build on Windows CI for reasons unknown
if impl(ghc >= 9.2) && os(windows) && impl(ghc < 9.4)
build-depends: fourmolu > 0.9.0.0 || < 0.9.0.0
6 changes: 3 additions & 3 deletions plugins/hls-fourmolu-plugin/src/Ide/Plugin/Fourmolu.hs
Original file line number Diff line number Diff line change
@@ -34,7 +34,6 @@ import Development.IDE.GHC.Compat as Compat hiding (Cpp, Warning,
import qualified Development.IDE.GHC.Compat.Util as S
import GHC.LanguageExtensions.Type (Extension (Cpp))
import Ide.Plugin.Error
import Ide.Plugin.Fourmolu.Shim
import Ide.Plugin.Properties
import Ide.PluginUtils (makeDiffTextEdit)
import Ide.Types
@@ -43,6 +42,7 @@ import Language.LSP.Protocol.Message
import Language.LSP.Protocol.Types
import Language.LSP.Server hiding (defaultConfig)
import Ormolu
import Ormolu.Config
import System.Exit
import System.FilePath
import System.Process.Run (cwd, proc)
@@ -87,9 +87,9 @@ provider recorder plId ideState typ contents fp fo = ExceptT $ withIndefinitePro
where
printerOpts = cfgFilePrinterOpts fourmoluConfig
config =
addFixityOverrides (cfgFileFixities fourmoluConfig) $
defaultConfig
{ cfgDynOptions = map DynOption fileOpts
, cfgFixityOverrides = cfgFileFixities fourmoluConfig
, cfgRegion = region
, cfgDebug = False
, cfgPrinterOpts =
@@ -112,7 +112,7 @@ provider recorder plId ideState typ contents fp fo = ExceptT $ withIndefinitePro
}
throwError $ PluginInternalError errorMessage
where
errorMessage = "Failed to load " <> T.pack f <> ": " <> T.pack (showParseError err)
errorMessage = "Failed to load " <> T.pack f <> ": " <> T.pack (show err)
where
fp' = fromNormalizedFilePath fp
title = "Formatting " <> T.pack (takeFileName fp')
75 changes: 0 additions & 75 deletions plugins/hls-fourmolu-plugin/src/Ide/Plugin/Fourmolu/Shim.hs

This file was deleted.

1 change: 0 additions & 1 deletion stack.yaml
Original file line number Diff line number Diff line change
@@ -46,7 +46,6 @@ extra-deps:
- hiedb-0.4.3.0
- implicit-hie-0.1.2.7
- implicit-hie-cradle-0.5.0.1
- fourmolu-0.12.0.0
- algebraic-graphs-0.6.1
- retrie-1.2.2
- hw-fingertree-0.1.2.1