feat(lsp): Support gotoDefinition from go->templ#932
Conversation
|
Sorry for a delay on this one. This is a great addition, many have said a pain point is gotodefinition from go to templ and this is the first step!
I wonder if we should add the docs for how to do the above along side this change? |
|
I looked at this the other day, and couldn't get it to work. Probably because I hadn't told my editor to use the templ LSP for Go files too, so I'd say we do need to do that. |
|
I have done it in my config for neovim, when it comes to other editors: Neovim: lspconfig change helix/emacs, will need PRs to the relevant repos Am i missing anything? |
|
I think that's correct yes. If we just update those things and there are no user config changes required apart from updating configs then maybe it's okay to merge this now at this point? Then we can gradually update the extensions etc? |
|
Is there any blockers for this, or anything further I can do to help move this along?
|
Just wondering, so with this approach one uses templ lsp for everything go, or does some dynamic handling to detect "if templ detected then templ lsp else gopls"? |
|
@Napam The templ lsp itself connects to a version of gopls, so you don't have to tell your editor to run both explicitly. The "if templ ..." stuff actually happens within templ itself. Therefore, with this PR if you configure neovim to run templ lsp for .go files it will handle it. There's nothing stopping you running both, but you might get multiple results for some actions. |
|
Thanks a lot for your work on this. I eventually got around to thinking about this, and put together two PRs at:
I don't think I would have got to it without your nudge. |
Support goToDefinition from a go file to a templ file.
Steps to test:
Caveats, because gopls and templ are attached, both references will be returned. Editor settings can be used to set preference to select from a list or go to the preferred option (probably the templ file)
When and if this was merged, it would need further adjustments to neovim/lspconfig to attach templ to go files too and would probably need a change in the vscode extension for the same
Closes #387