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) {
20 options.LicensesText = licensesText
22 options.ComputeEdits = ComputeEdits
24 options.URLRegexp = relaxedFullWord
25 options.GofumptFormat = func(ctx context.Context, src []byte) ([]byte, error) {
26 return format.Source(src, format.Options{})
28 updateAnalyzers(options)
31 var relaxedFullWord *regexp.Regexp
33 // Ensure links are matched as full words, not anywhere.
35 relaxedFullWord = regexp.MustCompile(`\b(` + xurls.Relaxed().String() + `)\b`)
36 relaxedFullWord.Longest()