gopls: add a hooks package

This allows us to hook functionality from the main tools repository with
alternate or extended implementations.

Change-Id: Ibc66cdd15ee80f1104a8464f1e28763a41d5765a
Reviewed-on: https://go-review.googlesource.com/c/tools/+/196319
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
This commit is contained in:
Ian Cottrell 2019-09-18 17:33:04 -04:00
parent db1d4edb46
commit c426260dee
2 changed files with 20 additions and 1 deletions

View File

@ -0,0 +1,16 @@
// Copyright 2019 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Package hooks adds all the standard gopls implementations.
// This can be used in tests without needing to use the gopls main, and is
// also the place to edit for custom builds of gopls.
package hooks // import "golang.org/x/tools/gopls/internal/hooks"
import (
"context"
)
func Install(ctx context.Context) context.Context {
return ctx
}

View File

@ -12,10 +12,13 @@ import (
"context"
"os"
"golang.org/x/tools/gopls/internal/hooks"
"golang.org/x/tools/internal/lsp/cmd"
"golang.org/x/tools/internal/tool"
)
func main() {
tool.Main(context.Background(), cmd.New("gopls", "", nil), os.Args[1:])
ctx := context.Background()
ctx = hooks.Install(ctx)
tool.Main(ctx, cmd.New("gopls", "", nil), os.Args[1:])
}