hls-brittany-plugin 1.0.0.1 → 1.0.0.2
raw patch · 3 files changed
+31/−35 lines, 3 filesdep −bytestringdep ~ghcidedep ~hls-plugin-apidep ~hls-test-utilsnew-uploaderPVP ok
version bump matches the API change (PVP)
Dependencies removed: bytestring
Dependency ranges changed: ghcide, hls-plugin-api, hls-test-utils
API changes (from Hackage documentation)
Files
- hls-brittany-plugin.cabal +5/−6
- src/Ide/Plugin/Brittany.hs +1/−2
- test/Main.hs +25/−27
hls-brittany-plugin.cabal view
@@ -1,6 +1,6 @@ cabal-version: 2.4 name: hls-brittany-plugin-version: 1.0.0.1+version: 1.0.0.2 synopsis: Integration with the Brittany code formatter description: Please see the README on GitHub at <https://github.com/haskell/haskell-language-server#readme>@@ -25,8 +25,8 @@ , filepath , ghc , ghc-boot-th- , ghcide ^>=1.2.0.0- , hls-plugin-api ^>=1.1+ , ghcide >=1.2 && <1.5+ , hls-plugin-api >=1.1 && <1.3 , lens , lsp-types , text@@ -42,7 +42,6 @@ ghc-options: -threaded -rtsopts -with-rtsopts=-N build-depends: , base- , bytestring+ , filepath , hls-brittany-plugin- , hls-test-utils ^>=1.0.0.0- , text+ , hls-test-utils >=1.0 && <1.2
src/Ide/Plugin/Brittany.hs view
@@ -6,7 +6,6 @@ import Control.Lens import Control.Monad.IO.Class import Control.Monad.Trans.Maybe (MaybeT, runMaybeT)-import Data.Coerce import Data.Maybe (mapMaybe, maybeToList) import Data.Semigroup import Data.Text (Text)@@ -81,7 +80,7 @@ runBrittany tabSize df confPath text = do let cfg = mempty { _conf_layout =- mempty { _lconfig_indentAmount = opt (coerce tabSize)+ mempty { _lconfig_indentAmount = opt (Last tabSize) } , _conf_forward = (mempty :: CForwardOptions Option)
test/Main.hs view
@@ -1,39 +1,37 @@ {-# LANGUAGE OverloadedStrings #-}-module Main(main) where+module Main+ ( main+ ) where -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.Brittany as Brittany+import qualified Ide.Plugin.Brittany as Brittany+import System.FilePath import Test.Hls main :: IO () main = defaultTestRunner tests -plugin :: PluginDescriptor IdeState-plugin = Brittany.descriptor "brittany"+brittanyPlugin :: PluginDescriptor IdeState+brittanyPlugin = Brittany.descriptor "brittany" tests :: TestTree-tests = testGroup "brittany" [- goldenGitDiff "formats a document with LF endings" "test/testdata/BrittanyLF.formatted_document.hs" $ runSessionWithServerFormatter plugin "brittany" "test/testdata" $ do- doc <- openDoc "BrittanyLF.hs" "haskell"- formatDoc doc (FormattingOptions 4 True Nothing Nothing Nothing)- BS.fromStrict . T.encodeUtf8 <$> documentContents doc+tests = testGroup "brittany"+ [ brittanyGolden "formats a document with LF endings" "BrittanyLF" "formatted_document" $ \doc -> do+ formatDoc doc (FormattingOptions 4 True Nothing Nothing Nothing) - , goldenGitDiff "formats a document with CRLF endings" "test/testdata/BrittanyCRLF.formatted_document.hs" $ runSessionWithServerFormatter plugin "brittany" "test/testdata" $ do- doc <- openDoc "BrittanyCRLF.hs" "haskell"- formatDoc doc (FormattingOptions 4 True Nothing Nothing Nothing)- BS.fromStrict . T.encodeUtf8 <$> documentContents doc+ , brittanyGolden "formats a document with CRLF endings" "BrittanyCRLF" "formatted_document" $ \doc -> do+ formatDoc doc (FormattingOptions 4 True Nothing Nothing Nothing) - , goldenGitDiff "formats a range with LF endings" "test/testdata/BrittanyLF.formatted_range.hs" $ runSessionWithServerFormatter plugin "brittany" "test/testdata" $ do- doc <- openDoc "BrittanyLF.hs" "haskell"- let range = Range (Position 1 0) (Position 2 22)- formatRange doc (FormattingOptions 4 True Nothing Nothing Nothing) range- BS.fromStrict . T.encodeUtf8 <$> documentContents doc+ , brittanyGolden "formats a range with LF endings" "BrittanyLF" "formatted_range" $ \doc -> do+ let range = Range (Position 1 0) (Position 2 22)+ formatRange doc (FormattingOptions 4 True Nothing Nothing Nothing) range - , goldenGitDiff "formats a range with CRLF endings" "test/testdata/BrittanyCRLF.formatted_range.hs" $ runSessionWithServerFormatter plugin "brittany" "test/testdata" $ do- doc <- openDoc "BrittanyCRLF.hs" "haskell"- let range = Range (Position 1 0) (Position 2 22)- formatRange doc (FormattingOptions 4 True Nothing Nothing Nothing) range- BS.fromStrict . T.encodeUtf8 <$> documentContents doc- ]+ , brittanyGolden "formats a range with CRLF endings" "BrittanyCRLF" "formatted_range" $ \doc -> do+ let range = Range (Position 1 0) (Position 2 22)+ formatRange doc (FormattingOptions 4 True Nothing Nothing Nothing) range+ ]++brittanyGolden :: TestName -> FilePath -> FilePath -> (TextDocumentIdentifier -> Session ()) -> TestTree+brittanyGolden title path desc = goldenWithHaskellDocFormatter brittanyPlugin "brittany" title testDataDir path desc "hs"++testDataDir :: FilePath+testDataDir = "test" </> "testdata"