Add logColor config option
[lsp-test.git] / example / Main.hs
index 8080991051ec609e297498b6d491ef14470c76af..7ee3f92cd414db960a5b14d98d3804d1745c6995 100644 (file)
@@ -1,16 +1,19 @@
-import Language.Haskell.LSP.Test
-import qualified Language.Haskell.LSP.TH.DataTypesJSON as LSP
-import qualified Data.Text.IO as T
-import Control.Lens
-import Control.Monad
+import Control.Applicative.Combinators
 import Control.Monad.IO.Class
-import System.Directory
-import System.Environment
+import Language.Haskell.LSP.Test
+import Language.Haskell.LSP.Types
+
+main = runSession "hie --lsp" fullCaps "test/data/renamePass" $ do
+  docItem <- openDoc "Desktop/simple.hs" "haskell"
+  
+  -- Use your favourite favourite combinators.
+  skipManyTill loggingNotification (count 2 publishDiagnosticsNotification)
+
+  -- Send requests and notifications and receive responses
+  let params = DocumentSymbolParams docItem
+  response <- sendRequest TextDocumentDocumentSymbol params :: Session DocumentSymbolsResponse
+  liftIO $ print response
+
+  -- Or use one of the helper functions
+  getDocumentSymbols docItem >>= liftIO . print
 
-main = do
-  files <- getArgs
-  forM_ files $ \fp -> session $ do
-    file <- liftIO $ canonicalizePath fp
-    openDocument file
-    symbols <- documentSymbols file
-    liftIO $ mapM_ T.putStrLn (symbols ^.. traverse . LSP.name)