default-language: Haskell2010
build-depends: base >= 4.7 && < 5
, haskell-lsp-types
- , haskell-lsp
+ , haskell-lsp >= 0.3
, aeson
, bytestring
, conduit
build-depends: base >= 4.7 && < 5
, hspec
, lens
+ , data-default
, directory
, haskell-lsp-test
, haskell-lsp
+ , haskell-lsp-types
, conduit
, conduit-parse
, aeson
-- * Sessions
runSession
, runSessionWithHandles
+ , runSessionWithCapabilities
, Session
-- * Sending
, sendRequest
import Data.List
import Language.Haskell.LSP.Types
import qualified Language.Haskell.LSP.Types as LSP (error, id)
+import Language.Haskell.LSP.TH.ClientCapabilities
import Language.Haskell.LSP.Messages
import Language.Haskell.LSP.VFS
import Language.Haskell.LSP.Test.Compat
-> FilePath -- ^ The filepath to the root directory for the session.
-> Session a -- ^ The session to run.
-> IO a
-runSession serverExe rootDir session = do
+runSession = runSessionWithCapabilities def
+
+-- | Starts a new sesion with a client with the specified capabilities.
+runSessionWithCapabilities :: ClientCapabilities -- ^ The capabilities the client should have.
+ -> String -- ^ The command to run the server.
+ -> FilePath -- ^ The filepath to the root directory for the session.
+ -> Session a -- ^ The session to run.
+ -> IO a
+runSessionWithCapabilities caps serverExe rootDir session = do
pid <- getProcessID
absRootDir <- canonicalizePath rootDir
(Just $ T.pack absRootDir)
(Just $ filePathToUri absRootDir)
Nothing
- def
+ caps
(Just TraceOff)
withServer serverExe $ \serverIn serverOut _ -> runSessionWithHandles serverIn serverOut listenServer rootDir $ do
withServer :: String -> (Handle -> Handle -> Int -> IO a) -> IO a
withServer serverExe f = do
+ -- TODO Probably should just change runServer to accept
+ -- separate command and arguments
let cmd:args = words serverExe
createProc = (proc cmd args) { std_in = CreatePipe, std_out = CreatePipe, std_err = CreatePipe }
(Just serverIn, Just serverOut, Just serverErr, serverProc) <- createProcess createProc
- .
extra-deps:
+ # - haskell-lsp
- github: Bubba/haskell-lsp-client
commit: b7cf14eb48837a73032e867dab90db1708220c66
- github: Bubba/haskell-lsp
- commit: 554b1535ae120f8541f860db5f131372da102bef
+ commit: 3e046bf095568099dae606e1c20a92f1dc60b7b9
subdirs:
- .
- ./haskell-lsp-types
{-# LANGUAGE DeriveAnyClass #-}
import Test.Hspec
import Data.Aeson
+import Data.Default
import qualified Data.HashMap.Strict as HM
import Data.Maybe
import Control.Monad.IO.Class
import GHC.Generics
import Language.Haskell.LSP.Test
import Language.Haskell.LSP.Test.Replay
+import Language.Haskell.LSP.TH.ClientCapabilities
import Language.Haskell.LSP.Types
import ParsingTests
rsp <- getInitializeResponse
liftIO $ rsp ^. result `shouldNotBe` Nothing
+ it "can register specific capabilities" $ do
+ let caps = def { _workspace = Just workspaceCaps }
+ workspaceCaps = def { _didChangeConfiguration = Just configCaps }
+ configCaps = DidChangeConfigurationClientCapabilities (Just True)
+ runSessionWithCapabilities caps "hie --lsp" "test/data/renamePass" $ return ()
+
describe "replay session" $ do
it "passes a test" $
replaySession "hie --lsp" "test/data/renamePass" `shouldReturn` True