1 // Copyright 2019 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
5 // Package hooks adds all the standard gopls implementations.
6 // This can be used in tests without needing to use the gopls main, and is
7 // also the place to edit for custom builds of gopls.
8 package hooks // import "golang.org/x/tools/gopls/internal/hooks"
14 "golang.org/x/tools/internal/lsp/source"
15 "mvdan.cc/gofumpt/format"
19 func Options(options *source.Options) {
21 options.ComputeEdits = ComputeEdits
23 options.URLRegexp = urlRegexp()
24 options.GofumptFormat = func(ctx context.Context, src []byte) ([]byte, error) {
25 return format.Source(src, format.Options{})
27 updateAnalyzers(options)
30 func urlRegexp() *regexp.Regexp {
31 // Ensure links are matched as full words, not anywhere.
32 re := regexp.MustCompile(`\b(` + xurls.Relaxed().String() + `)\b`)