nodeis installed. As explained at the node site you may need
npm install @types/nodefor the node runtime types
npm install typescript
nodeare in your execution path.
git clone firstname.lastname@example.org:microsoft/vscode-languageserver-node.git
To generate the protocol types (x/tools/internal/lsp/protocol/tsprotocol.go)
tsc go.ts && node go.js [-d dir] [-o out.go]
and for simple checking
gofmt -w out.go && golint out.go && go build out.go
-d dir names the directory into which the
vscode-languageserver-node repository was cloned. It defaults to
-o out.go says where the generated go code goes. It defaults to
To generate the client and server boilerplate (tsclient.go and tsserver.go)
tsc requests.ts && node requests.js [-d dir] && gofmt -w tsclient.go tsserver.go
-d dir is the same as above. The output files are written into the current directory.
requests.tsuse the Typescript compiler's API, which is introduced in their wiki.
request.tsare filled with heuristics and special cases. Therefore they are tied to a specific commit of
vscode-languageserver-node. The hash code of the commit is included in the header of
tsprotocol.goand stored in the variable
go.ts. It is checked (see
go.ts) on every execution of
ts*.gofiles is only semi-automated. Please file an issue if the released version is too far behind.
gitHashby hand (
git()shows how to find the hash).
requests.ts. This will likely fail because the heuristics don't cover some new case. For instance, some simple type like
stringmight have changed to a union type
string | [number,number]. (Look at the
UnionTypeNodecode near line 588 of
go.ts.) Another example is that some formal parameter generated by
requests.tswill have anonymous structure type, which is essentially unusable. (See the code related to
internal/lsp/protocoland try to build
goplsand its tests. This will likely fail because types have changed. Generally the fixes are fairly easy. (The code for
ourTypeswas a case where changes had to be made to
gopls. A common failure will be a nil dereference, because some previously simple default is now in an optional structure.