, rename
-- ** Hover
, getHover
+ -- ** Highlights
+ , getHighlights
-- ** Edits
, applyEdit
) where
-- ^ Returns the hover information at the specified position.
getHover :: TextDocumentIdentifier -> Position -> Session (Maybe Hover)
-getHover doc pos = do
+getHover doc pos =
let params = TextDocumentPositionParams doc pos
- getResponseResult <$> sendRequest TextDocumentHover params
+ in getResponseResult <$> sendRequest TextDocumentHover params
+
+getHighlights :: TextDocumentIdentifier -> Position -> Session [DocumentHighlight]
+getHighlights doc pos =
+ let params = TextDocumentPositionParams doc pos
+ in getResponseResult <$> sendRequest TextDocumentDocumentHighlight params
-- | Checks the response for errors and throws an exception if needed.
-- Returns the result if successful.
skipManyTill loggingNotification $ count 2 noDiagnostics
hover <- getHover doc (Position 45 9) -- putStrLn
liftIO $ hover `shouldSatisfy` isJust
+ describe "getHighlights" $
+ it "works" $ runSession "hie --lsp" "test/data/renamePass" $ do
+ doc <- openDoc "Desktop/simple.hs" "haskell"
+ skipManyTill loggingNotification $ count 2 noDiagnostics
+ highlights <- getHighlights doc (Position 27 4) -- addItem
+ liftIO $ length highlights `shouldBe` 4
mkRange sl sc el ec = Range (Position sl sc) (Position el ec)