Make ClientCapabilities a mandatory parameter
[lsp-test.git] / example / Main.hs
index 4dd268c907d8c96b8af2bee7b7eff27de2b2b4ad..a6bafe97d99edcaf499571ba97bcf100befdfbf3 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/recordings/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 -> manualSession $ do
-    file <- liftIO $ canonicalizePath fp
-    openDocument file
-    symbols <- documentSymbols file
-    liftIO $ mapM_ T.putStrLn (symbols ^.. traverse . LSP.name)