-
-
Notifications
You must be signed in to change notification settings - Fork 273
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
Suggestion: templ lsp
should print an error when gopls is not installed
#967
Comments
When I tried this I encountered this error: If you're not getting any error message printed, it's likely that the LSP is running properly when you run it from the command line and your editor isn't configured properly. You're saying that you ran |
Just one thought from me, are you sure there isn't another version of gopls hanging around somewhere? Try |
Can you run On my Mac, the output currently looks like this:
But let's also trace through the code just to make sure. The entrypoint of the Line 22 in bb5e41b
The LSP command is a subcommand: Line 56 in bb5e41b
So, it ends up running the public Line 378 in bb5e41b
There's a bit of setup: templ/cmd/templ/lspcmd/main.go Line 32 in bb5e41b
But then it ends up at templ/cmd/templ/lspcmd/main.go Line 72 in bb5e41b
And we see where the code starts gopls: templ/cmd/templ/lspcmd/main.go Lines 83 to 91 in bb5e41b
There's an info log item, there's a section at https://templ.guide/commands-and-tools/ide-support#troubleshooting-1 that mentions how to enable logs. Note that if an error is returned from templ/cmd/templ/lspcmd/main.go Lines 88 to 91 in bb5e41b
So, let's make sure that templ/cmd/templ/lspcmd/pls/main.go Lines 73 to 80 in bb5e41b
Here's the function that looks for templ/cmd/templ/lspcmd/pls/main.go Lines 34 to 70 in bb5e41b
I can't see a bug in there, but I guess there's a chance that you haven't set the executable bit on the |
Steps to reproduce:
gopls
is NOT installed.templ lsp
Expected behavior: an error message is printed, prompting the user to run
templ info
for more details.Actual behavior: nothing is printed at all
This was quite confusing to me as someone who is new to Go and Templ. Both Zed and VS Code printed cryptic error messages about a closed channel or something. I immediately checked the LSP logs for additional clues, but there was nothing. I then tried running
templ lsp
manually. When it silently exited I thought it had daemonized itself or something. It was only when I tried to kill the daemon that I realized it was not there and started running other cli commands out of desparation.This is not a bug and I expect a careful reading of the documentation would have given me some clues. But it seems like an opportunity to make a trivial change that could improve the experience for a percentage of new users. I work with several less common languages like Elixir, where buggy LSP servers are the norm, so I was perhaps slower to blame myself than I should have been.
v0.2.778
go1.23.2 darwin/amd64
gopls
version:golang.org/x/tools/gopls v0.16.2
The text was updated successfully, but these errors were encountered: