Skip to content

Commit f9889ae

Browse files
committed
Clean up stylish haskell plugin
1 parent ab6c0ec commit f9889ae

File tree

4 files changed

+20
-20
lines changed

4 files changed

+20
-20
lines changed

plugins/hls-stylish-haskell-plugin/hls-stylish-haskell-plugin.cabal

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,9 @@ library
2222
, filepath
2323
, ghc
2424
, ghc-boot-th
25-
, ghcide >=1.2 && <1.4
25+
, ghcide >=1.2 && <1.4
2626
, hls-plugin-api ^>=1.1
2727
, lsp-types
28-
, mtl
2928
, stylish-haskell ^>=0.12
3029
, text
3130

@@ -39,7 +38,6 @@ test-suite tests
3938
ghc-options: -threaded -rtsopts -with-rtsopts=-N
4039
build-depends:
4140
, base
42-
, bytestring
41+
, filepath
4342
, hls-stylish-haskell-plugin
4443
, hls-test-utils ^>=1.0
45-
, text

plugins/hls-stylish-haskell-plugin/src/Ide/Plugin/StylishHaskell.hs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{-# LANGUAGE OverloadedStrings #-}
22
module Ide.Plugin.StylishHaskell
3-
(
4-
descriptor
3+
( descriptor
54
, provider
65
)
76
where
@@ -18,7 +17,6 @@ import Ide.PluginUtils
1817
import Ide.Types
1918
import Language.Haskell.Stylish
2019
import Language.LSP.Types as J
21-
2220
import System.Directory
2321
import System.FilePath
2422

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,28 @@
11
{-# LANGUAGE OverloadedStrings #-}
2-
module Main(main) where
2+
module Main
3+
( main
4+
) where
35

4-
import qualified Data.ByteString.Lazy as BS
5-
import qualified Data.Text.Encoding as T
6-
import qualified Data.Text.IO as T
76
import qualified Ide.Plugin.StylishHaskell as StylishHaskell
7+
import System.FilePath
88
import Test.Hls
99

1010
main :: IO ()
1111
main = defaultTestRunner tests
1212

13-
plugin :: PluginDescriptor IdeState
14-
plugin = StylishHaskell.descriptor "stylishHaskell"
13+
stylishHaskellPlugin :: PluginDescriptor IdeState
14+
stylishHaskellPlugin = StylishHaskell.descriptor "stylishHaskell"
1515

1616
tests :: TestTree
17-
tests = testGroup "stylish-haskell" [
18-
goldenGitDiff "formats a document" "test/testdata/StylishHaskell.formatted_document.hs" $ runSessionWithServerFormatter plugin "stylishHaskell" "test/testdata" $ do
19-
doc <- openDoc "StylishHaskell.hs" "haskell"
17+
tests = testGroup "stylish-haskell"
18+
[ goldenWithStylishHaskell "formats a document" "StylishHaskell" "formatted_document" $ \doc -> do
2019
formatDoc doc (FormattingOptions 2 True Nothing Nothing Nothing)
21-
BS.fromStrict . T.encodeUtf8 <$> documentContents doc
22-
, goldenGitDiff "formats a range" "test/testdata/StylishHaskell.formatted_range.hs" $ runSessionWithServerFormatter plugin "stylishHaskell" "test/testdata" $ do
23-
doc <- openDoc "StylishHaskell.hs" "haskell"
20+
, goldenWithStylishHaskell "formats a range" "StylishHaskell" "formatted_range" $ \doc -> do
2421
formatRange doc (FormattingOptions 2 True Nothing Nothing Nothing) (Range (Position 0 0) (Position 2 21))
25-
BS.fromStrict . T.encodeUtf8 <$> documentContents doc
2622
]
23+
24+
goldenWithStylishHaskell :: TestName -> FilePath -> FilePath -> (TextDocumentIdentifier -> Session ()) -> TestTree
25+
goldenWithStylishHaskell title fp desc = goldenWithHaskellDoc stylishHaskellPlugin title testDataDir fp desc "hs"
26+
27+
testDataDir :: FilePath
28+
testDataDir = "test" </> "data"
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
cradle:
2+
direct:

0 commit comments

Comments
 (0)