"Go To Underlying Type" HLS Plugin draft

I got a prototype of the hyperlinks working:

type-hyperlinks

The problem is that we are using a markdown code block to render the type signature, and you can’t have links in that code block.

myThing :: [Type](file://typelink)

I tried with a <pre> tag but for some reason VS code will not display that at all. Though even if it worked we would’ve still lost the code highlighting.

3 Likes

Perhaps we can do something like:


myNestedType :: MyContainerType ExternalType

Defined at /home/random/haskell/underlying-type-plugin/app/Main.hs:9:3


You can use the inspector to see what HTML VSCode generates. I found it generates this in a test:

<span style="font-family: Menlo, Monaco, &quot;Courier New&quot;, monospace; font-weight: normal; font-size: 12px; font-feature-settings: &quot;liga&quot; 0, &quot;calt&quot; 0; font-variation-settings: normal; line-height: 18px; letter-spacing: 0px;">
	<div class="monaco-tokenized-source">
		<span class="mtk16">putStrLn</span>
		<span class="mtk1">
		</span>
		<span class="mtk3">::</span>
		<span class="mtk1">
		</span>
		<span class="mtk6">String</span>
		<span class="mtk1">
		</span>
		<span class="mtk3">-&gt;</span>
		<span class="mtk1">
		</span>
		<span class="mtk6">IO</span>
		<span class="mtk1"> ()</span>
	</div>
</span>

So perhaps something like that would work?

The problem is we can’t add class names in Markdown, so we will lose the code highlighting.

type-hyperlinks-2

I can imagine it getting cluttered so need to test with more types, but it’s really cool that you can use keyboard navigation.

Tagging some of the participants here for feedback before I proceed with this: @jaror @fendor @dschrempf @runeksvendsen @george.fst

3 Likes

Awesome, thank you for looking into this!

I think we want to keep the syntax highlighting in the hover, so the types themselves should probably not be clickable.
I like your idea to display the links in a separate section of the hover box! For reference, this is what rust-analyzer does:

This feels more compact, perhaps we want to copy this?

4 Likes

Yeah, this is much neater and can support a lot more types. Nice! If rust is doing it, then I guess we should be too. Before you know it, Haskell will be the new hot language everyone talks about!

3 Likes

This is now up in a PR that needs to be reviewed.

5 Likes

Looks great, @dnikolovv! Thank you for doing this.

1 Like