Generating LSP protocol Go types

122 views
Skip to first unread message

arn...@gmail.com

unread,
Jul 13, 2019, 10:43:32 AM7/13/19
to golang-nuts
Hi there,

I am trying to write a Go client for gopls.  Ideally I would like to be able to to import a package that defines Go types for all the messages that can be sent to / received from the server, which is something that obviously the gopls server also has to do.  Unfortunately the protocol files are not in a public package (https://github.com/golang/tools/tree/master/internal/lsp/protocol). There are instructions to generate the Go files at https://github.com/golang/tools/blob/master/internal/lsp/protocol/typescript/README.md but they require some files from that repository so that is not very useful.

Would it make sense for this to be extracted as a public package?  If so, how would I go about achieving this?  If not, what would be a sensible approach for me?

Regards,

Arnaud Delobelle

Peter Weinberger (温博格)

unread,
Jul 13, 2019, 11:05:36 AM7/13/19
to arn...@gmail.com, golang-nuts
I'm responsible for some of that code but other than that, I'm just giving my personal opinion.  There's no fundamental reason it couldn't be public, but,
1. They change all the time (weekly for some of it, more slowly for tsprotocol.go, which follows the Microsoft code)
2. They are adapted to the repository's version of gopls, and changes in gopls cause changes in these files.

One way to try things out is to clone the repository, and then in master, add your own git project. It has access to the internal files, but you'd push and pull it independently. That doesn't solve your problem, but maybe it delays it.

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/8fdc691a-345a-4162-a6cf-2e9b5cb078ec%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Paul Jolly

unread,
Jul 13, 2019, 1:48:17 PM7/13/19
to Peter Weinberger (温博格), arn...@gmail.com, golang-nuts
Just to add to Peter's response.

The issue tracking making these packages non-internal is
https://github.com/golang/go/issues/31080

FWIW, a number of people (myself included) simply clone the internal
packages for our own purposes. Here are those packages cloned, with
import paths changed:

https://github.com/myitcv/govim/tree/master/cmd/govim/internal

And here is the hacky script I used to clone those packages:

https://github.com/myitcv/govim/blob/master/_scripts/revendorToolsInternal.sh

Also, you may be interested in golang tools
(https://github.com/golang/go/wiki/golang-tools). There is a good
amount of discussion about this sort of thing in those various
channels


Paul
> To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CAOUkXSqVC07hpiPty3Yvi3g79itOWfg%2Br2Oz96NztDA10%2BLbTA%40mail.gmail.com.

arn...@gmail.com

unread,
Jul 29, 2019, 4:35:35 AM7/29/19
to golang-nuts
Thank you both for your help.  Looks like I will have to hack it somehow for the time being!

>> To unsubscribe from this group and stop receiving emails from it, send an email to golan...@googlegroups.com.
>> To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/8fdc691a-345a-4162-a6cf-2e9b5cb078ec%40googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google Groups "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to golan...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages