@@ -84,36 +84,41 @@ spec = do
8484 -- formatDoc doc (FormattingOptions 2 True)
8585 -- documentContents doc >>= liftIO . (`shouldBe` formattedBrittanyPostFloskell)
8686
87- -- describe "brittany" $ do
88- -- it "formats a document with LF endings" $ runSession hieCommand fullCaps "test/testdata" $ do
89- -- doc <- openDoc "BrittanyLF.hs" "haskell"
90- -- let opts = DocumentFormattingParams doc (FormattingOptions 4 True) Nothing
91- -- ResponseMessage _ _ (Just edits) _ <- request TextDocumentFormatting opts
92- -- liftIO $ edits `shouldBe` [TextEdit (Range (Position 0 0) (Position 3 0))
93- -- "foo :: Int -> String -> IO ()\nfoo x y = do\n print x\n return 42\n"]
94-
95- -- it "formats a document with CRLF endings" $ runSession hieCommand fullCaps "test/testdata" $ do
96- -- doc <- openDoc "BrittanyCRLF.hs" "haskell"
97- -- let opts = DocumentFormattingParams doc (FormattingOptions 4 True) Nothing
98- -- ResponseMessage _ _ (Just edits) _ <- request TextDocumentFormatting opts
99- -- liftIO $ edits `shouldBe` [TextEdit (Range (Position 0 0) (Position 3 0))
100- -- "foo :: Int -> String -> IO ()\nfoo x y = do\n print x\n return 42\n"]
101-
102- -- it "formats a range with LF endings" $ runSession hieCommand fullCaps "test/testdata" $ do
103- -- doc <- openDoc "BrittanyLF.hs" "haskell"
104- -- let range = Range (Position 1 0) (Position 2 22)
105- -- opts = DocumentRangeFormattingParams doc range (FormattingOptions 4 True) Nothing
106- -- ResponseMessage _ _ (Just edits) _ <- request TextDocumentRangeFormatting opts
107- -- liftIO $ edits `shouldBe` [TextEdit (Range (Position 1 0) (Position 3 0))
108- -- "foo x y = do\n print x\n return 42\n"]
109-
110- -- it "formats a range with CRLF endings" $ runSession hieCommand fullCaps "test/testdata" $ do
111- -- doc <- openDoc "BrittanyCRLF.hs" "haskell"
112- -- let range = Range (Position 1 0) (Position 2 22)
113- -- opts = DocumentRangeFormattingParams doc range (FormattingOptions 4 True) Nothing
114- -- ResponseMessage _ _ (Just edits) _ <- request TextDocumentRangeFormatting opts
115- -- liftIO $ edits `shouldBe` [TextEdit (Range (Position 1 0) (Position 3 0))
116- -- "foo x y = do\n print x\n return 42\n"]
87+ describe " brittany" $ do
88+ let formatLspConfig provider =
89+ object [ " languageServerHaskell" .= object [" formattingProvider" .= (provider :: Value )] ]
90+ it " formats a document with LF endings" $ runSession hieCommand fullCaps " test/testdata" $ do
91+ doc <- openDoc " BrittanyLF.hs" " haskell"
92+ sendNotification WorkspaceDidChangeConfiguration (DidChangeConfigurationParams (formatLspConfig " brittany" ))
93+ let opts = DocumentFormattingParams doc (FormattingOptions 4 True ) Nothing
94+ ResponseMessage _ _ (Just edits) _ <- request TextDocumentFormatting opts
95+ liftIO $ edits `shouldBe` [TextEdit (Range (Position 0 0 ) (Position 3 0 ))
96+ " foo :: Int -> String -> IO ()\n foo x y = do\n print x\n return 42\n " ]
97+
98+ it " formats a document with CRLF endings" $ runSession hieCommand fullCaps " test/testdata" $ do
99+ doc <- openDoc " BrittanyCRLF.hs" " haskell"
100+ sendNotification WorkspaceDidChangeConfiguration (DidChangeConfigurationParams (formatLspConfig " brittany" ))
101+ let opts = DocumentFormattingParams doc (FormattingOptions 4 True ) Nothing
102+ ResponseMessage _ _ (Just edits) _ <- request TextDocumentFormatting opts
103+ liftIO $ edits `shouldBe` [TextEdit (Range (Position 0 0 ) (Position 3 0 ))
104+ " foo :: Int -> String -> IO ()\n foo x y = do\n print x\n return 42\n " ]
105+
106+ it " formats a range with LF endings" $ runSession hieCommand fullCaps " test/testdata" $ do
107+ doc <- openDoc " BrittanyLF.hs" " haskell"
108+ sendNotification WorkspaceDidChangeConfiguration (DidChangeConfigurationParams (formatLspConfig " brittany" ))
109+ let range = Range (Position 1 0 ) (Position 2 22 )
110+ opts = DocumentRangeFormattingParams doc range (FormattingOptions 4 True ) Nothing
111+ ResponseMessage _ _ (Just edits) _ <- request TextDocumentRangeFormatting opts
112+ liftIO $ edits `shouldBe` [TextEdit (Range (Position 1 0 ) (Position 3 0 ))
113+ " foo x y = do\n print x\n return 42\n " ]
114+
115+ it " formats a range with CRLF endings" $ runSession hieCommand fullCaps " test/testdata" $ do
116+ doc <- openDoc " BrittanyCRLF.hs" " haskell"
117+ let range = Range (Position 1 0 ) (Position 2 22 )
118+ opts = DocumentRangeFormattingParams doc range (FormattingOptions 4 True ) Nothing
119+ ResponseMessage _ _ (Just edits) _ <- request TextDocumentRangeFormatting opts
120+ liftIO $ edits `shouldBe` [TextEdit (Range (Position 1 0 ) (Position 3 0 ))
121+ " foo x y = do\n print x\n return 42\n " ]
117122
118123 -- ---------------------------------
119124
0 commit comments