Skip to content

Use Hackage for Documentation and Source links#4746

Merged
fendor merged 2 commits into
haskell:masterfrom
Saizan:link-to-hackage
May 16, 2026
Merged

Use Hackage for Documentation and Source links#4746
fendor merged 2 commits into
haskell:masterfrom
Saizan:link-to-hackage

Conversation

@Saizan
Copy link
Copy Markdown
Contributor

@Saizan Saizan commented Oct 25, 2025

This is enabled by the new linkToHackage configuration option.

This is useful if you don't have local documentation or sources built, or other minor downsides of using local files. The vscode-haskell provides similar functionality but by trying to mangle the local file links, which is error prone because the path structure has changed between ghc versions.

If local documentation/source exists it gets used as a hint for which module to link to, which generally gives better results in case of re-exports. Otherwise we pick the module where the name is defined, and generate the link using its package name and version.

I am quite unsure if how I wired in the linkToHackage config option is appropriate. But I didn't want to do any refactor without some feedback first.

Initially I figured linkToHackage should be a plugin config for ghcide-hover-and-symbols, but the flag affects the GetDocMap rule which structurally appears to be more part of the core? The first way I wrote it I got import cycles so I backed off.

I am happy to have the flag where it is or move it if desired. And in any case I will split it into linkDocToHackage and linkSrcToHackage for flexibility.

Copy link
Copy Markdown
Collaborator

@fendor fendor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One suggestion and can we add a regression test case, somehow to make sure this doesn't accidentally break?

Otherwise, LGTM :)

Comment thread ghcide/src/Development/IDE/Types/Options.hs Outdated
@fendor fendor added the status: needs review This PR is ready for review label Nov 17, 2025
@Saizan Saizan force-pushed the link-to-hackage branch 2 times, most recently from 3f5aa28 to 4977a57 Compare February 14, 2026 17:43
@fendor fendor force-pushed the link-to-hackage branch from a5c9041 to 0ae5db3 Compare March 5, 2026 09:53
@fendor fendor requested a review from vidit-od March 5, 2026 09:55
@Saizan
Copy link
Copy Markdown
Contributor Author

Saizan commented Mar 5, 2026

@fendor I got a bit lost trying to add regression tests, would it look something like the ones in FindDefinitionAndHoverTests ?

@Saizan Saizan force-pushed the link-to-hackage branch from 0ae5db3 to 965a180 Compare March 5, 2026 13:03
Comment thread ghcide/src/Development/IDE/Spans/Documentation.hs Outdated
Comment thread ghcide/src/Development/IDE/Spans/Documentation.hs Outdated
@vidit-od
Copy link
Copy Markdown
Collaborator

vidit-od commented Mar 5, 2026

@Saizan Overall looks good,
regarding regression tests,

what you linked is a good pattern to follow, but from what i could see,
FindDefinitionAndHoverTests will use LinkToLocal by default. You'll need to write a separate test function that uses testithconfig with a custom Testconfig that sets to LinkToHackage maybe

Copy link
Copy Markdown
Collaborator

@fendor fendor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you!

I am wondering what the default should be and we need to add it as a vscode config as well, so the users can change it...

Should the default be LinkToHackage or do you prefer LinkToSource?

Comment thread ghcide-test/exe/FindDefinitionAndHoverTests.hs Outdated
@Saizan
Copy link
Copy Markdown
Contributor Author

Saizan commented May 13, 2026

I have been using LinkToHackage because I often don't have the local versions, however I figured we'd leave the old behavior as default

Copy link
Copy Markdown
Collaborator

@vidit-od vidit-od left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me as well !! LGTM !!

also, LinktoSource seems like a good default to me.

Comment thread ghcide/src/Development/IDE/Core/Rules.hs Outdated
@Saizan Saizan force-pushed the link-to-hackage branch from 0e6c7c7 to aa2fb24 Compare May 14, 2026 08:00
@fendor
Copy link
Copy Markdown
Collaborator

fendor commented May 15, 2026

also, LinktoSource seems like a good default to me.

In VSCode, this links to an HTML page which is not rendered, so I don't think that's a good default.

Screencast_20260515_111823.webm

however I figured we'd leave the old behavior as default

In VSCode, we rewrote this to hackage links, so it is not really the "default".
As the local sources aren't always available, I think we should use Hackage as the default.


Thus, I request to change the default to LinkToHackage, but I'll leave it up to @Saizan

@Saizan
Copy link
Copy Markdown
Contributor Author

Saizan commented May 15, 2026

It is properly rendered for me, but the links within it are opened in my actual browser, where they do not not resolve properly.

I'll make LinkToHackage the default for both documentation and source then.

@Saizan Saizan force-pushed the link-to-hackage branch 2 times, most recently from b2a9ddc to c267b95 Compare May 15, 2026 19:57
@Saizan Saizan force-pushed the link-to-hackage branch from c267b95 to bdf0d98 Compare May 16, 2026 08:40
@fendor fendor enabled auto-merge (squash) May 16, 2026 08:44
@fendor fendor merged commit 580098c into haskell:master May 16, 2026
42 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: needs review This PR is ready for review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants