node
and tsc
are installed. There are detailed instructions below.git clone git@github.com:microsoft vscode-languageserver-node.git
git checkout 635ab1f
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 $(HOME)
.
-o out.go
says where the generated go code goes. It defaults to tsprotocol.go
.
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.
go.ts
and requests.ts
use the Typescript compiler's API, which is introduced in their wiki.go.ts
and request.ts
are 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.go
and stored in the variable gitHash
in go.ts
. It is checked (see git()
in go.ts
) on every execution of go.ts
.ts*.go
files is only semi-automated. Please file an issue if the released version is too far behind.gitHash
by hand (git()
shows how to find the hash).go.ts
and requests.ts
. This will likely fail because the heuristics don't cover some new case. For instance, some simple type like string
might have changed to a union type string | [number,number]
. (Look at the UnionTypeNode
code near line 588 of go.ts
.) Another example is that some formal parameter generated by requests.ts
will have anonymous structure type, which is essentially unusable. (See the code related to ourTypes
.)internal/lsp/protocol
and try to build gopls
and its tests. This will likely fail because types have changed. Generally the fixes are fairly easy. (The code for ourTypes
was a case where changes had to be made to requests.ts
.)gopls
. A common failure will be a nil dereference, because some previously simple default is now in an optional structure.(The instructions are somewhat different for Linux and MacOS. They install some things locally, so $PATH
needs to be changed.)
sudo apt update
(if you can't sudo
these instructions are not helpful)sudo apt install nodejs
(this may install /usr/bin/nodejs
rather than /usr/bin/node
. For me, /usr/bin/nodejs
pointed to an actual executable /etc/alternatives/nodejs
, which should be copied to /usr/bin/node
)sudo apt intall npm
bin
directory in your path, perhaps?)sudo npm install -g npm
is the command.)node -v
and npm -v
should produce version numbers.npm install typescript
.npm
and node_modules
(and a package_lock.json
file)tsc
will be in node_modules/.bin
, so put that directory in your path.tsc -v
should print “Version 3.7.2” (or later). If not you may (as I did) have an obsolete tsc earlier in your path.npm install @types/node
(Without this there will be many incomprehensible typescript error messages.)