, getDefinitions
-- ** Renaming
, rename
+ -- ** Hover
+ , getHover
-- ** Edits
, applyEdit
) where
req = RequestMessage "" (IdInt 0) WorkspaceApplyEdit (ApplyWorkspaceEditParams wEdit)
updateState (ReqApplyWorkspaceEdit req)
+-- ^ Returns the hover information at the specified position.
+getHover :: TextDocumentIdentifier -> Position -> Session (Maybe Hover)
+getHover doc pos = do
+ let params = TextDocumentPositionParams doc pos
+ getResponseResult <$> sendRequest TextDocumentHover params
+
-- | Checks the response for errors and throws an exception if needed.
-- Returns the result if successful.
getResponseResult :: ResponseMessage a -> a
import Data.Aeson
import Data.Default
import qualified Data.HashMap.Strict as HM
+import Data.Maybe
import qualified Data.Text as T
import Control.Applicative.Combinators
import Control.Concurrent
rename doc (Position 1 0) "bar"
documentContents doc >>= liftIO . shouldBe "main = bar\nbar = return 42\n"
+ describe "getHover" $
+ it "works" $ runSession "hie --lsp" "test/data/renamePass" $ do
+ doc <- openDoc "Desktop/simple.hs" "haskell"
+ -- hover returns nothing until module is loaded
+ skipManyTill loggingNotification $ count 2 noDiagnostics
+ hover <- getHover doc (Position 45 9) -- putStrLn
+ liftIO $ hover `shouldSatisfy` isJust
+
mkRange sl sc el ec = Range (Position sl sc) (Position el ec)
didChangeCaps :: ClientCapabilities