github.com/v2fly/tools@v0.100.0/internal/lsp/helper/README.md (about) 1 # Generate server_gen.go 2 3 `helper` generates boilerplate code for server.go by processing the 4 generated code in `protocol/tsserver.go`. 5 6 First, build `helper` in this directory (`go build .`). 7 8 In directory `lsp`, executing `go generate server.go` generates the stylized file 9 `server_gen.go` that contains stubs for type `Server`. 10 11 It decides what stubs are needed and their signatures 12 by looking at the `Server` interface (`-t` flag). These all look somewhat like 13 `Resolve(context.Context, *CompletionItem) (*CompletionItem, error)`. 14 15 It then parses the `lsp` directory (`-u` flag) to see if there is a corresponding 16 implementation function (which in this case would be named `resolve`). If so 17 it discovers the parameter names needed, and generates (in `server_gen.go`) code 18 like 19 20 ``` go 21 func (s *Server) resolve(ctx context.Context, params *protocol.CompletionItem) (*protocol.CompletionItem, error) { 22 return s.resolve(ctx, params) 23 } 24 ``` 25 26 If `resolve` is not defined (and it is not), then the body of the generated function is 27 28 ```go 29 return nil, notImplemented("resolve") 30 ``` 31 32 So to add a capability currently not implemented, just define it somewhere in `lsp`. 33 In this case, just define `func (s *Server) resolve(...)` and re-generate `server_gen.go`.