packages feed

hls-fourmolu-plugin 1.0.0.0 → 1.0.0.1

raw patch · 11 files changed

+73/−95 lines, 11 filesdep −aesondep −bytestringdep −containersdep ~ghcidedep ~hls-plugin-apinew-uploaderPVP ok

version bump matches the API change (PVP)

Dependencies removed: aeson, bytestring, containers, data-default, extra, hspec-expectations, lsp-types, unordered-containers

Dependency ranges changed: ghcide, hls-plugin-api

API changes (from Hackage documentation)

Files

hls-fourmolu-plugin.cabal view
@@ -1,6 +1,6 @@ cabal-version:      2.4 name:               hls-fourmolu-plugin-version:            1.0.0.0+version:            1.0.0.1 synopsis:           Integration with the Fourmolu code formatter description:   Please see the README on GitHub at <https://github.com/haskell/haskell-language-server#readme>@@ -20,17 +20,15 @@   exposed-modules:  Ide.Plugin.Fourmolu   hs-source-dirs:   src   build-depends:-    , base            >=4.12     && <5-    , extra-    , fourmolu        ^>=0.3+    , base            >=4.12 && <5     , filepath+    , fourmolu        ^>=0.3     , ghc     , ghc-boot-th-    , ghcide           >=1.2 && <1.4+    , ghcide          >=1.2  && <1.5     , hls-plugin-api  ^>=1.1     , lens     , lsp-    , lsp-types     , text    default-language: Haskell2010@@ -43,18 +41,7 @@   ghc-options:      -threaded -rtsopts -with-rtsopts=-N   build-depends:     , base-    , bytestring-    , hls-fourmolu-plugin-    , text-    , data-default-    , hspec-expectations-    , lens-    , ghcide     , filepath-    , hls-test-utils ^>= 1.0-    , lsp-types-    , aeson-    , hls-plugin-api+    , hls-fourmolu-plugin+    , hls-test-utils        ^>=1.0     , lsp-test-    , containers-    , unordered-containers
src/Ide/Plugin/Fourmolu.hs view
@@ -1,7 +1,6 @@ {-# LANGUAGE DisambiguateRecordFields #-} {-# LANGUAGE LambdaCase               #-} {-# LANGUAGE OverloadedStrings        #-}-{-# LANGUAGE PackageImports           #-} {-# LANGUAGE TypeApplications         #-}  module Ide.Plugin.Fourmolu (@@ -9,26 +8,24 @@     provider, ) where -import           Control.Exception-import           Data.Either.Extra-import           System.FilePath-+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             as D hiding (pluginHandlers)+import           Development.IDE             hiding (pluginHandlers)+import           Development.IDE.GHC.Compat  (moduleNameString) import qualified DynFlags                    as D import qualified EnumSet                     as S-import           GHC                         (DynFlags, moduleNameString) import           GHC.LanguageExtensions.Type (Extension (Cpp)) import           GhcPlugins                  (HscEnv (hsc_dflags)) import           Ide.PluginUtils             (makeDiffTextEdit)--import           Control.Monad.IO.Class import           Ide.Types import           Language.LSP.Server         hiding (defaultConfig) import           Language.LSP.Types import           Language.LSP.Types.Lens-import           "fourmolu" Ormolu+import           Ormolu+import           System.FilePath  -- --------------------------------------------------------------------- @@ -48,7 +45,7 @@         Just df -> liftIO $ convertDynFlags df      let format printerOpts =-            mapLeft (responseError . ("Fourmolu: " <>) . T.pack . show)+            first (responseError . ("Fourmolu: " <>) . T.pack . show)                 <$> try @OrmoluException (makeDiffTextEdit contents <$> ormolu config fp' (T.unpack contents))           where             config =@@ -91,7 +88,7 @@         FormatRange (Range (Position sl _) (Position el _)) ->             RegionIndices (Just $ sl + 1) (Just $ el + 1) -convertDynFlags :: DynFlags -> IO [DynOption]+convertDynFlags :: D.DynFlags -> IO [DynOption] convertDynFlags df =     let pp = ["-pgmF=" <> p | not (null p)]         p = D.sPgm_F $ D.settings df
test/Main.hs view
@@ -1,36 +1,30 @@ {-# LANGUAGE OverloadedStrings #-}-module Main(main) where+module Main+  ( main+  ) where -import           Control.Monad.IO.Class-import           Data.Aeson-import qualified Data.ByteString.Lazy         as BS-import qualified Data.Text.Encoding           as T-import qualified Data.Text.IO                 as T+import qualified Ide.Plugin.Fourmolu as Fourmolu import           Language.LSP.Test import           Language.LSP.Types-import           Test.Hls-import qualified Ide.Plugin.Fourmolu  as Fourmolu import           System.FilePath+import           Test.Hls  main :: IO () main = defaultTestRunner tests -plugin :: PluginDescriptor IdeState-plugin = Fourmolu.descriptor "fourmolu"--testDataDir :: FilePath-testDataDir = "test/testdata/"+fourmoluPlugin :: PluginDescriptor IdeState+fourmoluPlugin = Fourmolu.descriptor "fourmolu"  tests :: TestTree tests = testGroup "fourmolu"-  [ goldenGitDiff "formats correctly" (testDataDir </> "Format.fourmolu.formatted.hs") $-    runSessionWithServerFormatter plugin "fourmolu" testDataDir $ do-        doc <- openDoc "Format.hs" "haskell"-        formatDoc doc (FormattingOptions 4 True Nothing Nothing Nothing)-        BS.fromStrict . T.encodeUtf8 <$> documentContents doc-  , goldenGitDiff "formats imports correctly" (testDataDir </> "Format2.fourmolu.formatted.hs") $-    runSessionWithServerFormatter plugin "fourmolu" testDataDir $ do-        doc <- openDoc "Format2.hs" "haskell"-        formatDoc doc (FormattingOptions 4 True Nothing Nothing Nothing)-        BS.fromStrict . T.encodeUtf8 <$> documentContents doc+  [ goldenWithFourmolu "formats correctly" "Fourmolu" "formatted" $ \doc -> do+      formatDoc doc (FormattingOptions 4 True Nothing Nothing Nothing)+  , goldenWithFourmolu "formats imports correctly" "Fourmolu" "formatted" $ \doc -> do+      formatDoc doc (FormattingOptions 4 True Nothing Nothing Nothing)   ]++goldenWithFourmolu :: TestName -> FilePath -> FilePath -> (TextDocumentIdentifier -> Session ()) -> TestTree+goldenWithFourmolu title path desc = goldenWithHaskellDocFormatter fourmoluPlugin "fourmolu" title testDataDir path desc "hs"++testDataDir :: FilePath+testDataDir = "test" </> "testdata"
− test/testdata/Format.fourmolu.formatted.hs
@@ -1,16 +0,0 @@-module Format where--import Data.List--import Data.Int-import Prelude--foo :: Int -> Int-foo 3 = 2-foo x = x-bar :: String -> IO String-bar s = do-    x <- return "hello"-    return "asdf"--data Baz = Baz {a :: Int, b :: String}
− test/testdata/Format.hs
@@ -1,15 +0,0 @@-module    Format where-import Data.List--import Prelude-import Data.Int-foo   :: Int ->  Int-foo  3 = 2-foo    x  = x-bar   :: String ->   IO String-bar s =  do-      x <- return "hello"-      return "asdf"--data Baz = Baz { a :: Int, b :: String }-
− test/testdata/Format2.fourmolu.formatted.hs
@@ -1,5 +0,0 @@-import Data.Bool-import Data.Char-import Data.Data-import Data.Either-import Data.Int
− test/testdata/Format2.hs
@@ -1,5 +0,0 @@-import Data.Char-import Data.Either-import Data.Int-import Data.Data-import Data.Bool
+ test/testdata/Fourmolu.formatted.hs view
@@ -0,0 +1,16 @@+module Fourmolu where++import Data.List++import Data.Int+import Prelude++foo :: Int -> Int+foo 3 = 2+foo x = x+bar :: String -> IO String+bar s = do+    x <- return "hello"+    return "asdf"++data Baz = Baz {a :: Int, b :: String}
+ test/testdata/Fourmolu.hs view
@@ -0,0 +1,15 @@+module    Fourmolu where+import Data.List++import Prelude+import Data.Int+foo   :: Int ->  Int+foo  3 = 2+foo    x  = x+bar   :: String ->   IO String+bar s =  do+      x <- return "hello"+      return "asdf"++data Baz = Baz { a :: Int, b :: String }+
+ test/testdata/Fourmolu2.formatted.hs view
@@ -0,0 +1,5 @@+import Data.Bool+import Data.Char+import Data.Data+import Data.Either+import Data.Int
+ test/testdata/Fourmolu2.hs view
@@ -0,0 +1,5 @@+import Data.Char+import Data.Either+import Data.Int+import Data.Data+import Data.Bool