feat: add support for starting gopls in shared daemon mode#1142
Conversation
|
Nice, I had a look at this a while ago as a part of a solution for getting "goToDefinition" from a go file to a templ file to work. I've tested this out locally, and works great. This may be something that would be valuable for most users, as it could make the LSP more efficient by spinning up 1 gopls rather than 2? I wonder if a docs entry just to point people in the correct direction might be worth it? |
joerdav
left a comment
There was a problem hiding this comment.
Great, looks good to me!
|
Thanks, @joerdav! I noticed the CI is failing with an HTTP 418 error when trying to download from what looks like a legacy GitHub Actions cache service. The error message says the service was shut down on April 15, 2025, and suggests migrating to the new system. Also, were you able to get navigation from Go to Templ working with these changes? I wasn't able to get it functioning on my end and had to use some internal tools to help bridge that gap in the developer experience. |
|
Yeah, I saw that! I'll take a look. We didn't end up getting that to work no. However there is a solution that works by running |
|
This will need rebasing on top of main for the CI/CD pipelines to run. |
|
Thanks for letting me know! Would it be possible to cut a new release that includes this change (in addition to a release for this change in the VS Code extension)? I realize there was a recent release, but it would be great to roll this out to our users. |
|
Thanks for your work on the LSP, much appreciated. |
|
@a-h @joerdav Also, just a quick update on your request about how we're using templ internally—we haven't forgotten! We've followed up several times with our Open Source Program Office, but it looks like they're currently short-staffed and not responding to requests across the company. We'll be sure to reach out as soon as we hear back from them. Thanks again! |
|
Got one more PR to review and merge. It's a good improvement to LSP functionality for partial templ files. Should be this weekend, I think. |
Templ LSP currently creates its own instance of Gopls. Gopls supports a shared daemon mode via the
-remoteflag, enabling multiple clients to connect to a single, long-lived Gopls instance.Add a
-gopls-remoteflag to thelspcommand to create or connect to a shared Gopls instance, improving efficiency and reducing overhead.Closes #1141.