haskell / haskell/haskell-language-server
Rewrite Documentation/Source links on hover to use local hoogle/hackage if available on nix and otherwise
- Dominant language
- Haskell
- Stars
- 3k
- Forks
- 455
- Avg merge
- 4d 3h
- Merged PRs (30d)
- 12
Description
## 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:
```diff
- 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:
```diff
- 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:
```diff
- /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](https://github.com/haskell/haskell-language-server/blob/53f61b4fa9182879614d33ccd74c2242c32edb4c/ghcide/src/Development/IDE/Spans/Documentation.hs#L104)
## Describe alternatives you've considered
A workaround described [here](https://github.com/haskell/haskell-language-server/issues/208#issuecomment-660701983):
> 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.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.