diff --git a/internal/lsp/cmd/serve.go b/internal/lsp/cmd/serve.go index ceca1f1d11..79b4546ee1 100644 --- a/internal/lsp/cmd/serve.go +++ b/internal/lsp/cmd/serve.go @@ -81,10 +81,11 @@ func (s *Serve) Run(ctx context.Context, args ...string) error { return s.forward() } - // For debugging purposes only. - run := func(ctx context.Context, srv *lsp.Server) { - go srv.Run(ctx) + prepare := func(ctx context.Context, srv *lsp.Server) *lsp.Server { + srv.Conn.AddHandler(&handler{}) + return srv } + run := func(ctx context.Context, srv *lsp.Server) { go prepare(ctx, srv).Run(ctx) } if s.Address != "" { return lsp.RunServerOnAddress(ctx, s.app.cache, s.Address, run) } @@ -96,7 +97,7 @@ func (s *Serve) Run(ctx context.Context, args ...string) error { stream = protocol.LoggingStream(stream, out) } ctx, srv := lsp.NewServer(ctx, s.app.cache, stream) - return srv.Run(ctx) + return prepare(ctx, srv).Run(ctx) } func (s *Serve) forward() error { @@ -119,9 +120,7 @@ func (s *Serve) forward() error { return <-errc } -type handler struct { - out io.Writer -} +type handler struct{} type rpcStats struct { method string