haskell / haskell/haskell-language-server

First hover differs from subsequent hovers

Open
#3,062 5 comments 2 reactions 0 assignees View on GitHub
component: ghcide status: needs info type: bug
Dominant language
Haskell
Stars
3k
Forks
455
Avg merge
4d 3h
Merged PRs (30d)
12

Description

When opening a file, the first hover request is missing some information (like description and documentation links) compared to later requests. This happens for each file opened for the first time during an HLS session. The RPC requests appears to be identical (except for the `id` field), so I'm ruling out the client as a source of the issue.

https://user-images.githubusercontent.com/2512008/180772348-e88aa0d0-61e6-445f-8a77-2e633a4f65b0.mp4

### Your environment

Which OS do you use?

NixOS

Which version of GHC do you use and how did you install it?

9.0.2 from Nix

How is your project built (alternative: link to the project)?

I can reproduce this issue with both Cabal and standalone modules/files.

Which LSP client (editor/plugin) do you use?

Neovim LSP client

Which version of HLS do you use and how did you install it?

1.7.0.0 from Nix

Have you configured HLS in any way (especially: a `hie.yaml` file)?

Using `implicit-hie` for Cabal projects, no configuration for standalone modules/files.

### Steps to reproduce

1. Open a file.
2. Hover on a non-local symbol.
3. Close the preview.
4. Hover on the same symbol again.

### Expected behaviour

First hover should give the same information as the second hover.

### Actual behaviour

First hover is missing information like description and documentation links.

### Debug information

LSP logs for the first hover:
```
[DEBUG][2022-07-21 22:16:15] .../lua/vim/lsp.lua:1023 "LSP[hls]" "client.request" 1 "textDocument/hover" { position = { character = 7, line = 3 }, textDocument = { uri = "file:///home/evenbrenden/Downloads/Main.hs" }} 1
[DEBUG][2022-07-21 22:16:15] .../vim/lsp/rpc.lua:347 "rpc.send" { id = 2, jsonrpc = "2.0", method = "textDocument/hover", params = { position = { character = 7, line = 3 }, textDocument = { uri = "file:///home/evenbrenden/Downloads/Main.hs" } }}
[ERROR][2022-07-21 22:16:15] .../vim/lsp/rpc.lua:420 "rpc" "haskell-language-server-wrapper" "stderr" "2022-07-21T20:16:15.387204Z | Debug | GhcIde.hover entered (ideLogger)\n2022-07-21T20:16:15.387370Z | Debug | Hover request at position 4:8 in file: /home/evenbrenden/Downloads/Main.hs\n2022-07-21T20:16:15.387562Z | Debug | LOOKUP UP PERSISTENT FOR: GetDocMap\n2022-07-21T20:16:15.387647Z | Debug | Finished: C:GetHieAst:/home/evenbrenden/Downloads/Main.hs Took: 0.00s\n2022-07-21T20:16:15.387647Z | Debug | Finished: C:GhcSession:/home/evenbrenden/Downloads/Main.hs Took: 0.00s\n"
[DEBUG][2022-07-21 22:16:15] .../vim/lsp/rpc.lua:454 "rpc.receive" { jsonrpc = "2.0", method = "window/logMessage", params = { message = "GhcIde.hover entered (ideLogger)", type = 4 }}
[DEBUG][2022-07-21 22:16:15] .../vim/lsp/rpc.lua:454 "rpc.receive" { jsonrpc = "2.0", method = "window/logMessage", params = { message = "Hover request at position 4:8 in file: /home/evenbrenden/Downloads/Main.hs", type = 4 }}
[DEBUG][2022-07-21 22:16:15] .../vim/lsp/rpc.lua:454 "rpc.receive" { jsonrpc = "2.0", method = "window/logMessage", params = { message = "LOOKUP UP PERSISTENT FOR: GetDocMap", type = 4 }}
[DEBUG][2022-07-21 22:16:15] .../vim/lsp/rpc.lua:454 "rpc.receive" { id = 2, jsonrpc = "2.0", result = { contents = { kind = "markdown", value = "\n```haskell\nreturn :: forall (m :: * -> *) a. Monad m => a -> m a\n```\n\n*Defined in ‘GHC.Base’*\n *(base-4.15.1.0)*\n* * *\n\n```haskell\n$dMonad :: Monad IO\n```\n\n* * *\n\n```haskell\n_ :: () -> IO ()\n```\n* * *\n\n```haskell\n_ :: forall (m :: * -> *) a. Monad m => a -> m a\n```\n" }, range = { end = { character = 13, line = 3 }, start = { character = 7, line = 3 } } }}
[ERROR][2022-07-21 22:16:15] .../vim/lsp/rpc.lua:420 "rpc" "haskell-language-server-wrapper" "stderr" "2022-07-21T20:16:15.390021Z | Debug | Finished: C:GetDocMap:/home/evenbrenden/Downloads/Main.hs Took: 0.00s\n"
[DEBUG][2022-07-21 22:16:15] .../vim/lsp/rpc.lua:454 "rpc.receive" { jsonrpc = "2.0", method = "window/logMessage", params = { message = "Finished: C:GetHieAst:/home/evenbrenden/Downloads/Main.hs Took: 0.00s", type = 4 }}
[DEBUG][2022-07-21 22:16:15] .../vim/lsp/rpc.lua:454 "rpc.receive" { jsonrpc = "2.0", method = "window/logMessage", params = { message = "Finished: C:GhcSession:/home/evenbrenden/Downloads/Main.hs Took: 0.00s", type = 4 }}
[DEBUG][2022-07-21 22:16:15] .../vim/lsp/rpc.lua:454 "rpc.receive" { jsonrpc = "2.0", method = "window/logMessage", params = { message = "Finished: C:GetDocMap:/home/evenbrenden/Downloads/Main.hs Took: 0.00s", type = 4 }}
[INFO][2022-07-21 22:16:15] ...lsp/handlers.lua:458 "GhcIde.hover entered (ideLogger)"
[INFO][2022-07-21 22:16:15] ...lsp/handlers.lua:458 "Hover request at position 4:8 in file: /home/evenbrenden/Downloads/Main.hs"
[INFO][2022-07-21 22:16:15] ...lsp/handlers.lua:458 "LOOKUP UP PERSISTENT FOR: GetDocMap"
[INFO][2022-07-21 22:16:15] ...lsp/handlers.lua:458 "Finished: C:GetHieAst:/home/evenbrenden/Downloads/Main.hs Took: 0.00s"
[INFO][2022-07-21 22:16:15] ...lsp/handlers.lua:458 "Finished: C:GhcSession:/home/evenbrenden/Downloads/Main.hs Took: 0.00s"
[INFO][2022-07-21 22:16:15] ...lsp/handlers.lua:458 "Finished: C:GetDocMap:/home/evenbrenden/Downloads/Main.hs Took: 0.00s"
```

LSP log for the second hover:
```
[DEBUG][2022-07-21 22:16:18] .../lua/vim/lsp.lua:1023 "LSP[hls]" "client.request" 1 "textDocument/hover" { position = { character = 7, line = 3 }, textDocument = { uri = "file:///home/evenbrenden/Downloads/Main.hs" }} 1
[DEBUG][2022-07-21 22:16:18] .../vim/lsp/rpc.lua:347 "rpc.send" { id = 3, jsonrpc = "2.0", method = "textDocument/hover", params = { position = { character = 7, line = 3 }, textDocument = { uri = "file:///home/evenbrenden/Downloads/Main.hs" } }}
[ERROR][2022-07-21 22:16:18] .../vim/lsp/rpc.lua:420 "rpc" "haskell-language-server-wrapper" "stderr" "2022-07-21T20:16:18.184501Z | Debug | GhcIde.hover entered (ideLogger)\n2022-07-21T20:16:18.184760Z | Debug | Hover request at position 4:8 in file: /home/evenbrenden/Downloads/Main.hs\n2022-07-21T20:16:18.185066Z | Debug | Finished: C:GhcSession:/home/evenbrenden/Downloads/Main.hs Took: 0.00s\n2022-07-21T20:16:18.185068Z | Debug | Finished: C:GetHieAst:/home/evenbrenden/Downloads/Main.hs Took: 0.00s\n2022-07-21T20:16:18.186434Z | Debug | Finished: C:GetDocMap:/home/evenbrenden/Downloads/Main.hs Took: 0.00s\n"
[DEBUG][2022-07-21 22:16:18] .../vim/lsp/rpc.lua:454 "rpc.receive" { jsonrpc = "2.0", method = "window/logMessage", params = { message = "GhcIde.hover entered (ideLogger)", type = 4 }}
[DEBUG][2022-07-21 22:16:18] .../vim/lsp/rpc.lua:454 "rpc.receive" { jsonrpc = "2.0", method = "window/logMessage", params = { message = "Hover request at position 4:8 in file: /home/evenbrenden/Downloads/Main.hs", type = 4 }}
[DEBUG][2022-07-21 22:16:18] .../vim/lsp/rpc.lua:454 "rpc.receive" { id = 3, jsonrpc = "2.0", result = { contents = { kind = "markdown", value = "\n```haskell\nreturn :: forall (m :: * -> *) a. Monad m => a -> m a\n```\n\n*Defined in ‘GHC.Base’*\n *(base-4.15.1.0)*\n\n\nInject a value into the monadic type.\n\n[Documentation](file:///nix/store/5xxas1y13lirgyb67g22j38fvnbsvrrb-ghc-9.0.2-doc/share/doc/ghc/html/libraries/base-4.15.1.0/GHC-Base.html#v:return)\n\n[Source](file:///nix/store/5xxas1y13lirgyb67g22j38fvnbsvrrb-ghc-9.0.2-doc/share/doc/ghc/html/libraries/base-4.15.1.0/src/GHC-Base.html#return)\n\n\n* * *\n\n```haskell\n$dMonad :: Monad IO\n```\n\n* * *\n\n```haskell\n_ :: () -> IO ()\n```\n* * *\n\n```haskell\n_ :: forall (m :: * -> *) a. Monad m => a -> m a\n```\n" }, range = { end = { character = 13, line = 3 }, start = { character = 7, line = 3 } } }}
[DEBUG][2022-07-21 22:16:18] .../vim/lsp/rpc.lua:454 "rpc.receive" { jsonrpc = "2.0", method = "window/logMessage", params = { message = "Finished: C:GhcSession:/home/evenbrenden/Downloads/Main.hs Took: 0.00s", type = 4 }}
[DEBUG][2022-07-21 22:16:18] .../vim/lsp/rpc.lua:454 "rpc.receive" { jsonrpc = "2.0", method = "window/logMessage", params = { message = "Finished: C:GetHieAst:/home/evenbrenden/Downloads/Main.hs Took: 0.00s", type = 4 }}
[DEBUG][2022-07-21 22:16:18] .../vim/lsp/rpc.lua:454 "rpc.receive" { jsonrpc = "2.0", method = "window/logMessage", params = { message = "Finished: C:GetDocMap:/home/evenbrenden/Downloads/Main.hs Took: 0.00s", type = 4 }}
[INFO][2022-07-21 22:16:18] ...lsp/handlers.lua:458 "GhcIde.hover entered (ideLogger)"
[INFO][2022-07-21 22:16:18] ...lsp/handlers.lua:458 "Hover request at position 4:8 in file: /home/evenbrenden/Downloads/Main.hs"
[INFO][2022-07-21 22:16:18] ...lsp/handlers.lua:458 "Finished: C:GhcSession:/home/evenbrenden/Downloads/Main.hs Took: 0.00s"
[INFO][2022-07-21 22:16:18] ...lsp/handlers.lua:458 "Finished: C:GetHieAst:/home/evenbrenden/Downloads/Main.hs Took: 0.00s"
[INFO][2022-07-21 22:16:18] ...lsp/handlers.lua:458 "Finished: C:GetDocMap:/home/evenbrenden/Downloads/Main.hs Took: 0.00s"
```

Full LSP log for the session: [lsp.log](https://github.com/haskell/haskell-language-server/files/9180839/lsp.log)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.