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

VSCode LSP request failed #956

Open
morigs opened this issue Oct 10, 2024 · 2 comments
Open

VSCode LSP request failed #956

morigs opened this issue Oct 10, 2024 · 2 comments

Comments

@morigs
Copy link

morigs commented Oct 10, 2024

Describe the bug
When opening minimal templ project in VSCode I get the following error: Request textDocument/prepareCallHierarchy failed

To Reproduce

// main.go
package main

import (
	"context"
	"os"
)

func main() {
	component := hello("john")
	component.Render(context.Background(), os.Stdout)
}
package main

templ hello(name string) {
	<div>{ name }</div>
}

Expected behavior
No error

Screenshots
image

Logs

[Error - 15:12:51] Request textDocument/prepareCallHierarchy failed.
  Message: no package metadata for file file:///~/templ-tests/hello.templ
  Code: 0

I replace path to file from absolute to relative.

templ info output

(✓) os [ goos=darwin goarch=arm64 ]
(✓) go [ location=/opt/homebrew/bin/go version=go version go1.23.2 darwin/arm64 ]
(✓) gopls [ location=/Users/morigs/go/bin/gopls version=golang.org/x/tools/gopls v0.16.2 ]
(✓) templ [ location=/Users/morigs/go/bin/templ version=v0.2.778 ]

Desktop (please complete the following information):

  • OS: MacOS
  • templ CLI version: v0.2.778
  • Go version go version go1.23.2 darwin/arm64
  • gopls version (golang.org/x/tools/gopls v0.16.2)

Additional context

I've tried to restart vscode, close other apps, killing all gopls and templ instances, but no luck

@a-h
Copy link
Owner

a-h commented Dec 28, 2024

Did you create a go.mod file by running go mod init github.com/morigs/templ-tests? Without a go.mod file, the Go language server won't be able to run.

If you can create an example and share it, I'd be able to look at it.

@morigs
Copy link
Author

morigs commented Jan 9, 2025

Yes, I have the go.mod. The problem is still present on the latest version of VSCode and Templ extension.
Here's the reproduction:
https://github.com/morigs/templ-tests

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

No branches or pull requests

2 participants