haskell / haskell-ide-engine

The engine for haskell ide-integration. Not an IDE
BSD 3-Clause "New" or "Revised" License
2.38k stars 211 forks source link

Hover doesn't show documentation for some functions #1567

Open hasufell opened 4 years ago

hasufell commented 4 years ago

https://files.gitter.im/neoclide/coc.nvim/dyC6/Screenshot_2020-01-08_22-19-03.png

https://files.gitter.im/neoclide/coc.nvim/dyC6/Screenshot_2020-01-08_22-19-18.png

But the completion does, which sends a different request (don't know which). The hover request indeed does not return any documentation:

[Trace - 10:27:10 PM] Sending request 'textDocument/hover - (748)'.
Params: {
    "textDocument": {
        "uri": "file:///home/jule/git/hpath/hpath-io/src/HPath/IO.hs"
    },
    "position": {
        "line": 444,
        "character": 18
    }
}

[Trace - 10:27:10 PM] Received response 'textDocument/hover - (748)' in 2ms.
Result: {
    "contents": {
        "kind": "markdown",
        "value": "\n```haskell\nuserError :: String -> IOError\n```\n```haskell\nuserError :: String -> IOError\n```\n\n\n\nbase GHC.IO.Exception"
    },
    "range": {
        "start": {
            "line": 444,
            "character": 14
        },
        "end": {
            "line": 444,
            "character": 23
        }
    }
}

Completion request:

[Trace - 10:42:42 PM] Sending request 'completionItem/resolve - (868)'.
Params: {
    "insertText": "userError",
    "kind": 3,
    "data": {
        "name_details": [
            "GHC.IO.Exception",
            "base",
            "v",
            "userError"
        ],
        "hoogle_query": "userError module:Prelude is:exact"
    },
    "insertTextFormat": 1,
    "label": "userError",
    "detail": "Prelude"
}

[Trace - 10:42:42 PM] Received response 'completionItem/resolve - (868)' in 12ms.
Result: {
    "insertText": "userError ${1:String}",
    "kind": 3,
    "data": {
        "name_details": [
            "GHC.IO.Exception",
            "base",
            "v",
            "userError"
        ],
        "hoogle_query": "userError module:Prelude is:exact"
    },
    "insertTextFormat": 2,
    "documentation": {
        "kind": "markdown",
        "value": "```haskell\nuserError :: String -> IOError\n```\nConstruct an `IOError` value with a string describing the error.\nThe `fail` method of the `IO` instance of the `Monad`\nclass raises a `userError`, thus:\n\n```haskell\n\ninstance Monad IO where\n...\nfail s = ioError (userError s)\n```\n\n[More info](https://hackage.haskell.org/package/base/docs/Prelude.html#v:userError)"
    },
    "label": "userError",
    "detail": "String -> IOError\nPrelude"
}
hasufell commented 4 years ago

Correction: it doesn't happen for all functions, but for some. Seems especially with stuff in prelude.

georgefst commented 4 years ago

Have you manually built documentation with either Haddock or Hoogle? Otherwise documentation will only be available for libraries that ship with GHC.

If you're using cabal 3 to build your project, then rebuilding after running cabal configure --enable-documentation should do the job.

There is some discussion about hie managing this automatically at #1285.

hasufell commented 4 years ago

Have you manually built documentation with either Haddock or Hoogle?

Yes.

If you're using cabal 3 to build your project, then rebuilding after running cabal configure --enable-documentation should do the job

That is already enabled in cabal.project.

As I said. Documentation shows up in auto-complete, not in hover. That looks like a straight bug to me.

fendor commented 4 years ago

Can not reprodoce with vscode.

hasufell commented 4 years ago

Can not reprodoce with vscode.

I tried in vscode, same.

hasufell commented 4 years ago

After some more testing, I think it might be related to the documentation not being built. However, it's confusing that the autocomplete still shows it, isn't it?

fendor commented 4 years ago

I agree, it is definitely weird