Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(lsp): Support gotoDefinition from go->templ #932

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

tris203
Copy link
Contributor

@tris203 tris203 commented Sep 24, 2024

Support goToDefinition from a go file to a templ file.

Steps to test:

  1. Attach both gopls and templ lsp to a main.go buffer
  2. GoToDefinition
  3. Profit

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

@joerdav
Copy link
Collaborator

joerdav commented Jan 27, 2025

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!

Editor settings can be used to set preference to select from a list or go to the preferred option (probably the templ file)

I wonder if we should add the docs for how to do the above along side this change?

@a-h
Copy link
Owner

a-h commented Jan 27, 2025

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.

@tris203
Copy link
Contributor Author

tris203 commented Jan 27, 2025

I have done it in my config for neovim, when it comes to other editors:

Neovim: lspconfig change
VSCode: I assume an extension change

helix/emacs, will need PRs to the relevant repos

Am i missing anything?

@joerdav
Copy link
Collaborator

joerdav commented Jan 28, 2025

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

lsp: Support goToDefinition from a Go file to a templ file
4 participants