X-Git-Url: http://git.lukelau.me/?a=blobdiff_plain;f=src%2FLanguage%2FHaskell%2FLSP%2FTest.hs;h=0e8f5bfcaa92259f253defa2d89bbb40610c1e66;hb=563d0885c5cf4456ea04c041771d68dca5c274d4;hp=eb09d826a82f05d5015dfabecd5c85ce4e35cb5c;hpb=57bc413473ab2900cae76ce54c3d49a8937e3562;p=opengl.git diff --git a/src/Language/Haskell/LSP/Test.hs b/src/Language/Haskell/LSP/Test.hs index eb09d82..0e8f5bf 100644 --- a/src/Language/Haskell/LSP/Test.hs +++ b/src/Language/Haskell/LSP/Test.hs @@ -93,6 +93,7 @@ import Language.Haskell.LSP.Test.Exceptions import Language.Haskell.LSP.Test.Parsing import Language.Haskell.LSP.Test.Session import Language.Haskell.LSP.Test.Server +import System.Console.ANSI import System.IO import System.Directory import System.FilePath @@ -121,7 +122,7 @@ runSessionWithConfig config serverExe rootDir session = do Nothing (capabilities config) (Just TraceOff) - withServer serverExe $ \serverIn serverOut _ -> + withServer serverExe (logStdErr config) $ \serverIn serverOut _ -> runSessionWithHandles serverIn serverOut listenServer config rootDir $ do -- Wrap the session around initialize and shutdown calls @@ -159,14 +160,8 @@ listenServer serverOut = do -- | The current text contents of a document. documentContents :: TextDocumentIdentifier -> Session T.Text documentContents doc = do - vfs' <- vfs <$> get - let docUri = doc ^. uri - file <- case Map.lookup docUri vfs' of - Just file -> return file - Nothing -> do - openDoc (fromJust (uriToFilePath docUri)) "" - newVfs <- vfs <$> get - return $ newVfs Map.! docUri + vfs <- vfs <$> get + let file = vfs Map.! (doc ^. uri) return $ Rope.toText $ Language.Haskell.LSP.VFS._text file -- | Parses an ApplyEditRequest, checks that it is for the passed document @@ -279,7 +274,16 @@ sendResponse = sendMessage sendMessage :: ToJSON a => a -> Session () sendMessage msg = do h <- serverIn <$> ask - liftIO $ B.hPut h $ addHeader (encode msg) + let encoded = encode msg + liftIO $ do + + setSGR [SetColor Foreground Vivid Cyan] + putStrLn $ "--> " ++ B.unpack encoded + setSGR [Reset] + + B.hPut h (addHeader encoded) + + -- | Returns the initialize response that was received from the server. -- The initialize requests and responses are not included the session,