From d6553e001f5134401aef1c676817211947740583 Mon Sep 17 00:00:00 2001 From: Jan Hrcek <2716069+jhrcek@users.noreply.github.com> Date: Tue, 23 Jan 2024 12:36:05 +0100 Subject: [PATCH] Fix -Wall and -Wunused-packages in fourmolu and ormolu plugins (#4007) Co-authored-by: Michael Peyton Jones --- plugins/hls-fourmolu-plugin/hls-fourmolu-plugin.cabal | 10 ++++++---- plugins/hls-ormolu-plugin/hls-ormolu-plugin.cabal | 9 +++++---- plugins/hls-ormolu-plugin/src/Ide/Plugin/Ormolu.hs | 8 ++------ plugins/hls-ormolu-plugin/test/Main.hs | 7 ++++--- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/plugins/hls-fourmolu-plugin/hls-fourmolu-plugin.cabal b/plugins/hls-fourmolu-plugin/hls-fourmolu-plugin.cabal index ae72cb643c..f50437b46c 100644 --- a/plugins/hls-fourmolu-plugin/hls-fourmolu-plugin.cabal +++ b/plugins/hls-fourmolu-plugin/hls-fourmolu-plugin.cabal @@ -22,16 +22,18 @@ source-repository head type: git location: git://github.com/haskell/haskell-language-server.git +common warnings + ghc-options: -Wall -Wunused-packages + library + import: warnings exposed-modules: Ide.Plugin.Fourmolu hs-source-dirs: src - ghc-options: -Wall build-depends: , base >=4.12 && <5 , filepath , fourmolu ^>= 0.14 - , ghc , ghc-boot-th , ghcide == 2.6.0.0 , hls-plugin-api == 2.6.0.0 @@ -45,17 +47,17 @@ library default-language: Haskell2010 test-suite tests + import: warnings type: exitcode-stdio-1.0 default-language: Haskell2010 hs-source-dirs: test main-is: Main.hs - ghc-options: -Wall -threaded -rtsopts -with-rtsopts=-N + ghc-options: -threaded -rtsopts -with-rtsopts=-N build-tool-depends: fourmolu:fourmolu build-depends: , base >=4.12 && <5 , aeson - , containers , filepath , hls-fourmolu-plugin , hls-plugin-api diff --git a/plugins/hls-ormolu-plugin/hls-ormolu-plugin.cabal b/plugins/hls-ormolu-plugin/hls-ormolu-plugin.cabal index 7b980c0fca..3a655b6814 100644 --- a/plugins/hls-ormolu-plugin/hls-ormolu-plugin.cabal +++ b/plugins/hls-ormolu-plugin/hls-ormolu-plugin.cabal @@ -22,18 +22,20 @@ source-repository head type: git location: https://github.com/haskell/haskell-language-server.git +common warnings + ghc-options: -Wall -Wunused-packages + library + import: warnings exposed-modules: Ide.Plugin.Ormolu hs-source-dirs: src build-depends: , base >=4.12 && <5 , extra , filepath - , ghc , ghc-boot-th , ghcide == 2.6.0.0 , hls-plugin-api == 2.6.0.0 - , lens , lsp , mtl , process-extras >= 0.7.1 @@ -44,6 +46,7 @@ library default-language: Haskell2010 test-suite tests + import: warnings type: exitcode-stdio-1.0 default-language: Haskell2010 hs-source-dirs: test @@ -54,11 +57,9 @@ test-suite tests build-depends: , base , aeson - , containers , filepath , hls-ormolu-plugin , hls-plugin-api , hls-test-utils == 2.6.0.0 , lsp-types - , text , ormolu diff --git a/plugins/hls-ormolu-plugin/src/Ide/Plugin/Ormolu.hs b/plugins/hls-ormolu-plugin/src/Ide/Plugin/Ormolu.hs index 042cbcce7c..0d40ff986f 100644 --- a/plugins/hls-ormolu-plugin/src/Ide/Plugin/Ormolu.hs +++ b/plugins/hls-ormolu-plugin/src/Ide/Plugin/Ormolu.hs @@ -16,13 +16,10 @@ where import Control.Exception (Handler (..), IOException, SomeException (..), catches, handle) -import Control.Monad.Except (ExceptT (ExceptT), runExceptT, - throwError) +import Control.Monad.Except (runExceptT, throwError) import Control.Monad.Extra -import Control.Monad.IO.Class (liftIO) import Control.Monad.Trans -import Control.Monad.Trans.Except (ExceptT (..), mapExceptT, - runExceptT) +import Control.Monad.Trans.Except (ExceptT (..), mapExceptT) import Data.Functor ((<&>)) import Data.List (intercalate) import Data.Maybe (catMaybes) @@ -38,7 +35,6 @@ import Ide.Plugin.Properties import Ide.PluginUtils import Ide.Types hiding (Config) import qualified Ide.Types as Types -import Language.LSP.Protocol.Message import Language.LSP.Protocol.Types import Language.LSP.Server hiding (defaultConfig) import Ormolu diff --git a/plugins/hls-ormolu-plugin/test/Main.hs b/plugins/hls-ormolu-plugin/test/Main.hs index 1dd8f9b3d4..512a7c343f 100644 --- a/plugins/hls-ormolu-plugin/test/Main.hs +++ b/plugins/hls-ormolu-plugin/test/Main.hs @@ -5,8 +5,8 @@ module Main ) where import Data.Aeson +import qualified Data.Aeson.KeyMap as KM import Data.Functor -import qualified Data.Text as T import Ide.Plugin.Config import qualified Ide.Plugin.Ormolu as Ormolu import Language.LSP.Protocol.Types @@ -34,9 +34,10 @@ tests = testGroup "ormolu" $ ] goldenWithOrmolu :: Bool -> TestName -> FilePath -> FilePath -> (TextDocumentIdentifier -> Session ()) -> TestTree -goldenWithOrmolu cli title path desc = goldenWithHaskellDocFormatter def ormoluPlugin "ormolu" def title testDataDir path desc "hs" +goldenWithOrmolu cli title path desc = + goldenWithHaskellDocFormatter def ormoluPlugin "ormolu" conf title testDataDir path desc "hs" where - conf = def{plcConfig = (\(Object obj) -> obj) $ object ["external" .= cli]} + conf = def{plcConfig = KM.fromList ["external" .= cli]} testDataDir :: FilePath testDataDir = "test" "testdata"