Skip to content

Rewrite Documentation/Source links on hover to use local hoogle/hackage if available on nix and otherwise #3475

Open
@ParetoOptimalDev

Description

@ParetoOptimalDev

Is your enhancement request related to a problem? Please describe.

This request is similar to #208, but slightly different? At least the fact that this issue is focused on nix support makes it different, but the implementation of this could satisfy both issues I believe.

Even when I have a local instance of hoogle running at localhost:8888 the links I click for source and documentation go to http://haskell.org.

NOTE: I use nix's withHaddock feature for this

For instance I'm linked to:

https://hackage.haskell.org/package/apecs-0.9.4/docs/Apecs-Util.html#v:newEntity_

When I'd prefer to be linked to:

http://localhost:8888/file/nix/store/pmyb1ayz7vxlmim1bd12sjpss3s7pddy-apecs-0.9.4-doc/share/doc/apecs-0.9.4/html/Apecs.html#v:newEntity_

Describe the solution you'd like

For HLS to check to see if a hoogle instance is running and if it's fingerprint is a nix server, rewrite urls like:

- https://hackage.haskell.org/package/apecs-0.9.4/docs/Apecs-Util.html#v:newEntity_
+ http://localhost:8888/file/nix/store/pmyb1ayz7vxlmim1bd12sjpss3s7pddy-apecs-0.9.4-doc/share/doc/apecs-0.9.4/html/Apecs.html#v:newEntity_

And for source:

- https://hackage.haskell.org/package/apecs-0.9.4/docs/src/Apecs.Util.html#newEntity_
+ http://localhost:8888/file/nix/store/pmyb1ayz7vxlmim1bd12sjpss3s7pddy-apecs-0.9.4-doc/share/doc/apecs-0.9.4/html/src/Apecs.Util.html#newEntity_

Looking at the above, the common replacement within the urls is:

- /package/apecs-0.9.4/docs
+/file/nix/store/pmyb1ayz7vxlmim1bd12sjpss3s7pddy-apecs-0.9.4-doc/share/doc/apecs-0.9.4/html

You can get this variable in recent versions of Nix's haskellPackages from the environmental variable $NIX_GHC_DOCDIR.

NOTE: I believe the code to change is in Development.IDE.Spans.Documentation.getDocumentationsTryGhc

Describe alternatives you've considered

A workaround described here:

A possible workaround is to active documentation generation for all dependant packages adding in the cabal.project:

package * 
  documentation: true

To be frank though, I'd just never do that and probably forget it was ever an option.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions