From 8342138ef7b2f1171321c26b51abe219a189eb39 Mon Sep 17 00:00:00 2001 From: George Thomas Date: Mon, 4 Oct 2021 10:13:50 +0100 Subject: [PATCH 01/11] Allow Fourmolu 0.4 --- cabal.project | 2 +- plugins/hls-fourmolu-plugin/hls-fourmolu-plugin.cabal | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cabal.project b/cabal.project index 50d1ffbbd1..08c0fbbdd5 100644 --- a/cabal.project +++ b/cabal.project @@ -38,7 +38,7 @@ package * write-ghc-environment-files: never -index-state: 2021-09-16T07:00:23Z +index-state: 2021-10-04T02:41:06Z constraints: hyphenation +embed diff --git a/plugins/hls-fourmolu-plugin/hls-fourmolu-plugin.cabal b/plugins/hls-fourmolu-plugin/hls-fourmolu-plugin.cabal index 15970d4d13..339408dc93 100644 --- a/plugins/hls-fourmolu-plugin/hls-fourmolu-plugin.cabal +++ b/plugins/hls-fourmolu-plugin/hls-fourmolu-plugin.cabal @@ -22,7 +22,7 @@ library build-depends: , base >=4.12 && <5 , filepath - , fourmolu ^>=0.3 + , fourmolu ^>=0.3 || ^>=0.4 , ghc , ghc-boot-th , ghcide >=1.2 && <1.5 From bc56d49a231e7d6873b419c44fdfd392815f75bd Mon Sep 17 00:00:00 2001 From: George Thomas Date: Mon, 4 Oct 2021 10:19:25 +0100 Subject: [PATCH 02/11] Reformat record construction to Fourmolu style --- plugins/hls-fourmolu-plugin/src/Ide/Plugin/Fourmolu.hs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/hls-fourmolu-plugin/src/Ide/Plugin/Fourmolu.hs b/plugins/hls-fourmolu-plugin/src/Ide/Plugin/Fourmolu.hs index b65405a802..07fce8afb3 100644 --- a/plugins/hls-fourmolu-plugin/src/Ide/Plugin/Fourmolu.hs +++ b/plugins/hls-fourmolu-plugin/src/Ide/Plugin/Fourmolu.hs @@ -70,10 +70,10 @@ provider ideState typ contents fp fo = withIndefiniteProgress title Cancellable format mempty ConfigParseError f (_, err) -> do sendNotification SWindowShowMessage $ - ShowMessageParams - { _xtype = MtError - , _message = errorMessage - } + ShowMessageParams + { _xtype = MtError + , _message = errorMessage + } return . Left $ responseError errorMessage where errorMessage = "Failed to load " <> T.pack f <> ": " <> T.pack err From c96314d2dc8ca629ffb1c1d308839a0ce6b09f68 Mon Sep 17 00:00:00 2001 From: George Thomas Date: Mon, 4 Oct 2021 10:19:48 +0100 Subject: [PATCH 03/11] Run stylish-haskell on imports --- .../src/Ide/Plugin/Fourmolu.hs | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/plugins/hls-fourmolu-plugin/src/Ide/Plugin/Fourmolu.hs b/plugins/hls-fourmolu-plugin/src/Ide/Plugin/Fourmolu.hs index 07fce8afb3..990e5c9745 100644 --- a/plugins/hls-fourmolu-plugin/src/Ide/Plugin/Fourmolu.hs +++ b/plugins/hls-fourmolu-plugin/src/Ide/Plugin/Fourmolu.hs @@ -8,19 +8,19 @@ module Ide.Plugin.Fourmolu ( provider, ) where -import Control.Exception (try) -import Control.Lens ((^.)) +import Control.Exception (try) +import Control.Lens ((^.)) import Control.Monad.IO.Class -import Data.Bifunctor (first) -import qualified Data.Text as T -import Development.IDE hiding (pluginHandlers) -import Development.IDE.GHC.Compat as Compat hiding (Cpp) +import Data.Bifunctor (first) +import qualified Data.Text as T +import Development.IDE hiding (pluginHandlers) +import Development.IDE.GHC.Compat as Compat hiding (Cpp) import qualified Development.IDE.GHC.Compat.Util as S -import GHC.LanguageExtensions.Type (Extension (Cpp)) -import GhcPlugins (HscEnv (hsc_dflags)) -import Ide.PluginUtils (makeDiffTextEdit) +import GHC.LanguageExtensions.Type (Extension (Cpp)) +import GhcPlugins (HscEnv (hsc_dflags)) +import Ide.PluginUtils (makeDiffTextEdit) import Ide.Types -import Language.LSP.Server hiding (defaultConfig) +import Language.LSP.Server hiding (defaultConfig) import Language.LSP.Types import Language.LSP.Types.Lens import Ormolu From ed50c8bdc54eadff5b8aea4732120a644c58bb1d Mon Sep 17 00:00:00 2001 From: Javier Neira Date: Mon, 4 Oct 2021 11:39:28 +0200 Subject: [PATCH 04/11] Enable fourmolu for ghc-9 --- cabal-ghc901.project | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cabal-ghc901.project b/cabal-ghc901.project index 325b3763b7..6b37a4c776 100644 --- a/cabal-ghc901.project +++ b/cabal-ghc901.project @@ -9,7 +9,7 @@ packages: -- ./plugins/hls-tactics-plugin -- ./plugins/hls-brittany-plugin -- ./plugins/hls-stylish-haskell-plugin - -- ./plugins/hls-fourmolu-plugin + ./plugins/hls-fourmolu-plugin -- ./plugins/hls-class-plugin ./plugins/hls-eval-plugin ./plugins/hls-explicit-imports-plugin @@ -61,11 +61,11 @@ source-repository-package write-ghc-environment-files: never -index-state: 2021-09-16T07:00:23Z +index-state: 2021-10-04T02:41:06Z constraints: -- These plugins don't work on GHC9 yet - haskell-language-server -brittany -class -fourmolu -stylishhaskell -tactic + haskell-language-server -brittany -class -stylishhaskell -tactic allow-newer: floskell:base, From cd016ec40b2a96231bd625d937b11fbb187577e3 Mon Sep 17 00:00:00 2001 From: Javier Neira Date: Mon, 4 Oct 2021 11:40:36 +0200 Subject: [PATCH 05/11] Enable fourmolu tests for ghc-9 --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 659b6df72f..884140c4e6 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -196,7 +196,7 @@ jobs: name: Test hls-ormolu-plugin run: cabal test hls-ormolu-plugin --test-options="-j1 --rerun-update" || cabal test hls-ormolu-plugin --test-options="-j1 --rerun" || LSP_TEST_LOG_COLOR=0 LSP_TEST_LOG_MESSAGES=true LSP_TEST_LOG_STDERR=true cabal test hls-ormolu-plugin --test-options="-j1 --rerun" - - if: ${{ needs.pre_job.outputs.should_skip != 'true' && matrix.test && matrix.ghc != '9.0.1' }} + - if: ${{ needs.pre_job.outputs.should_skip != 'true' && matrix.test }} name: Test hls-fourmolu-plugin run: cabal test hls-fourmolu-plugin --test-options="-j1 --rerun-update" || cabal test hls-fourmolu-plugin --test-options="-j1 --rerun" || LSP_TEST_LOG_COLOR=0 LSP_TEST_LOG_MESSAGES=true LSP_TEST_LOG_STDERR=true cabal test hls-fourmolu-plugin --test-options="-j1 --rerun" From c540450a607c3729dcff0afaf0965faefa6fcd3b Mon Sep 17 00:00:00 2001 From: Javier Neira Date: Mon, 4 Oct 2021 12:07:20 +0200 Subject: [PATCH 06/11] Enable fourmolu for ghc-9 and stack --- stack-9.0.1.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/stack-9.0.1.yaml b/stack-9.0.1.yaml index 7de85baba2..69d1a7ff3f 100644 --- a/stack-9.0.1.yaml +++ b/stack-9.0.1.yaml @@ -22,7 +22,7 @@ packages: # - ./plugins/hls-brittany-plugin # - ./plugins/hls-stylish-haskell-plugin - ./plugins/hls-floskell-plugin - # - ./plugins/hls-fourmolu-plugin + # ./plugins/hls-fourmolu-plugin - ./plugins/hls-pragmas-plugin - ./plugins/hls-module-name-plugin - ./plugins/hls-ormolu-plugin @@ -38,6 +38,7 @@ extra-deps: - dependent-sum-0.7.1.0@sha256:0e419237f5b86da3659772afff9cab355c0f8d5b3fdb15a5b30e673d8dc83941,2147 - extra-1.7.9 - floskell-0.10.5 +- fourmolu-0.4.0.0 - ghc-source-gen-0.4.1.0 - heapsize-0.3.0.1@sha256:0b69aa97a46d819b700ac7b145f3b5493c3565cf2c5b8298682238d405d0326e,1417 - hie-bios-0.7.6 From b16a0288ce9598cf99689131bb37071b26a5461b Mon Sep 17 00:00:00 2001 From: Javier Neira Date: Mon, 4 Oct 2021 12:08:17 +0200 Subject: [PATCH 07/11] Correct stack-9.0.1.yaml changes --- stack-9.0.1.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/stack-9.0.1.yaml b/stack-9.0.1.yaml index 69d1a7ff3f..bce2b857d5 100644 --- a/stack-9.0.1.yaml +++ b/stack-9.0.1.yaml @@ -22,7 +22,7 @@ packages: # - ./plugins/hls-brittany-plugin # - ./plugins/hls-stylish-haskell-plugin - ./plugins/hls-floskell-plugin - # ./plugins/hls-fourmolu-plugin + - ./plugins/hls-fourmolu-plugin - ./plugins/hls-pragmas-plugin - ./plugins/hls-module-name-plugin - ./plugins/hls-ormolu-plugin @@ -107,7 +107,6 @@ flags: class: false tactic: false # Dependencies fail - fourmolu: false stylishHaskell: false brittany: false retrie: From ddfe0204569d00635e28d384badd9eeba12193bd Mon Sep 17 00:00:00 2001 From: George Thomas Date: Mon, 4 Oct 2021 11:51:32 +0100 Subject: [PATCH 08/11] Use explicit import to avoid shadowing --- plugins/hls-fourmolu-plugin/src/Ide/Plugin/Fourmolu.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/hls-fourmolu-plugin/src/Ide/Plugin/Fourmolu.hs b/plugins/hls-fourmolu-plugin/src/Ide/Plugin/Fourmolu.hs index 990e5c9745..da057494d6 100644 --- a/plugins/hls-fourmolu-plugin/src/Ide/Plugin/Fourmolu.hs +++ b/plugins/hls-fourmolu-plugin/src/Ide/Plugin/Fourmolu.hs @@ -22,7 +22,7 @@ import Ide.PluginUtils (makeDiffTextEdit) import Ide.Types import Language.LSP.Server hiding (defaultConfig) import Language.LSP.Types -import Language.LSP.Types.Lens +import Language.LSP.Types.Lens (HasTabSize (tabSize)) import Ormolu import System.FilePath From 46d3264ea057bcf9ec0db3d770a372321c938100 Mon Sep 17 00:00:00 2001 From: George Thomas Date: Mon, 4 Oct 2021 11:51:49 +0100 Subject: [PATCH 09/11] Remove unused import --- plugins/hls-fourmolu-plugin/src/Ide/Plugin/Fourmolu.hs | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins/hls-fourmolu-plugin/src/Ide/Plugin/Fourmolu.hs b/plugins/hls-fourmolu-plugin/src/Ide/Plugin/Fourmolu.hs index da057494d6..e38ed0028c 100644 --- a/plugins/hls-fourmolu-plugin/src/Ide/Plugin/Fourmolu.hs +++ b/plugins/hls-fourmolu-plugin/src/Ide/Plugin/Fourmolu.hs @@ -17,7 +17,6 @@ import Development.IDE hiding (pluginHandlers) import Development.IDE.GHC.Compat as Compat hiding (Cpp) import qualified Development.IDE.GHC.Compat.Util as S import GHC.LanguageExtensions.Type (Extension (Cpp)) -import GhcPlugins (HscEnv (hsc_dflags)) import Ide.PluginUtils (makeDiffTextEdit) import Ide.Types import Language.LSP.Server hiding (defaultConfig) From 3f45fac7910d991cb317c44b291215cad1a0c2fa Mon Sep 17 00:00:00 2001 From: George Thomas Date: Mon, 4 Oct 2021 12:02:41 +0100 Subject: [PATCH 10/11] Bump plugin version --- plugins/hls-fourmolu-plugin/hls-fourmolu-plugin.cabal | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/hls-fourmolu-plugin/hls-fourmolu-plugin.cabal b/plugins/hls-fourmolu-plugin/hls-fourmolu-plugin.cabal index 339408dc93..483d8653c3 100644 --- a/plugins/hls-fourmolu-plugin/hls-fourmolu-plugin.cabal +++ b/plugins/hls-fourmolu-plugin/hls-fourmolu-plugin.cabal @@ -1,6 +1,6 @@ cabal-version: 2.4 name: hls-fourmolu-plugin -version: 1.0.0.2 +version: 1.0.1.0 synopsis: Integration with the Fourmolu code formatter description: Please see the README on GitHub at From 7c4261235f7ece50751ac1853c2b454bc43f4242 Mon Sep 17 00:00:00 2001 From: George Thomas Date: Mon, 4 Oct 2021 12:05:47 +0100 Subject: [PATCH 11/11] Enable -Wall --- plugins/hls-fourmolu-plugin/hls-fourmolu-plugin.cabal | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/hls-fourmolu-plugin/hls-fourmolu-plugin.cabal b/plugins/hls-fourmolu-plugin/hls-fourmolu-plugin.cabal index 483d8653c3..3645687550 100644 --- a/plugins/hls-fourmolu-plugin/hls-fourmolu-plugin.cabal +++ b/plugins/hls-fourmolu-plugin/hls-fourmolu-plugin.cabal @@ -19,6 +19,7 @@ extra-source-files: library exposed-modules: Ide.Plugin.Fourmolu hs-source-dirs: src + ghc-options: -Wall build-depends: , base >=4.12 && <5 , filepath @@ -38,7 +39,7 @@ test-suite tests default-language: Haskell2010 hs-source-dirs: test main-is: Main.hs - ghc-options: -threaded -rtsopts -with-rtsopts=-N + ghc-options: -Wall -threaded -rtsopts -with-rtsopts=-N build-depends: , base , filepath