a-h / templ

A language for writing HTML user interfaces in Go.
https://templ.guide/
MIT License
7.33k stars 240 forks source link

lsp: Inlay Hint Support #627

Open hmnd opened 4 months ago

hmnd commented 4 months ago

It would be great if the templ LSP supported inlay hints.

Currently, I tend to lean toward providing an options struct as a single param to my templ components, because it can be difficult to figure out what a bunch of strings args are supposed to represent. That comes with the caveat of structs not enforcing that all params are provided, leading to unintentional defaults.

Inlay hints would allow one to efficiently parse what each arg means, without the sacrifices in explicitness that a struct requires.

Thanks for your work on this awesome lib!

joerdav commented 1 month ago

Just to outline the steps involved to get this off the ground:

  1. Update the protocol package to support the textDocument/inlayHint command.
  2. Implement the command in the server proxy, mapping the positions in the response from go to templ (the inverse of updatePosition).
  3. Add a configuration option to the lsp enable the various hints gopls provides, as gopls doesn't provide them by default therefore we shouldn't.
  4. Add configuration options to the editor plugins to configure hints (vscode, nvim).