Rename sendRequest to request, sendRequest' to sendRequest
[opengl.git] / example / Main.hs
index 4dd268c907d8c96b8af2bee7b7eff27de2b2b4ad..1e2e3baf3356b36f6eb09967a02ce2e7fbd12c0a 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
+  rsp <- request TextDocumentDocumentSymbol params :: Session DocumentSymbolsResponse
+  liftIO $ print rsp
+
+  -- Or use one of the helper functions
+  getDocumentSymbols docItem >>= liftIO . print
 
-main = do
-  files <- getArgs
-  forM_ files $ \fp -> manualSession $ do
-    file <- liftIO $ canonicalizePath fp
-    openDocument file
-    symbols <- documentSymbols file
-    liftIO $ mapM_ T.putStrLn (symbols ^.. traverse . LSP.name)