haskell / haskell-language-server

Official haskell ide support via language server (LSP). Successor of ghcide & haskell-ide-engine.
Apache License 2.0
2.71k stars 367 forks source link

Add Haddock hyperlinks to hover for type holes #390

Open sheaf opened 4 years ago

sheaf commented 4 years ago

I would find it very helpful if the hover information could include links to Haddock documentation (if documentation is available).

A common situation when working with an unfamiliar library is needing to pass an argument to a function say foo, and a typical workflow would be to start writing:

where
  x = foo a b _notsure ( d e )

then hover over _notsure to find its expected type. Ideally then I'd be able to see the type needed, and be able to click on it for the documentation. For instance:

hover_hyperlink

I'd like to be able to open up this documentation:

gdk_windowhints

Having taken a quick look at how hover information is created, I don't see how to simultaneously include hyperlinks and have syntax highlighting, as the current hover information is typeset by encoding it in a Haskell markdown codeblock.

Currently, hover information is available for set functions, e.g.:

hover_doc

Something similar could be done in the previous situation, including a link to WindowHints, but that still seems a bit limited to me as the type might be something more complex and I might want to click on some component of it. It's especially annoying as if I click on the documentation for windowSetGeometryHints in the previous example, I can't then click on Geometry or WindowHints to get to that part of the documentation because of ghcide !61, as those are part of the gi-gdk package (whereas windowSetGeometryHints comes from the gi-gtk package).

jneira commented 3 years ago

I think hover already have links like that, @sheaf could you try last hls version to check it, please?

Ailrun commented 3 years ago

Maybe not directly related, it would be great if we can go to the document by hovering on a module name.

sheaf commented 3 years ago

@jneira The only hover links are those that say "Documentation" and go to the haddock page like I showed in the OP. As far as I'm aware the situation hasn't changed: if you hover over a hole and specific types are mentioned, there aren't any documentation links.

jneira commented 3 years ago

ops sorry, i mirsunderstood the feature requested, you want to have the link in the "error" for the type hole, as well it is already in the function, thanks for the clarification

sheaf commented 3 years ago

Yes, although "as well as it is already in the function" is not entirely accurate.

When I want to know how to use a function from the library, yes, I can hover over the function and go to the documentation.
However, when I have a typed hole somewhere in my program and hover over it, there is no mechanism that links to any documentation. There might not be a library function anywhere that I could hover over to get a documentation link.