.gitignore added
[dotfiles/.git] / .config / coc / extensions / coc-go-data / tools / pkg / mod / golang.org / x / tools / gopls@v0.6.9 / internal / hooks / hooks.go
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.
4
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"
9
10 import (
11         "context"
12         "regexp"
13
14         "golang.org/x/tools/internal/lsp/source"
15         "mvdan.cc/gofumpt/format"
16         "mvdan.cc/xurls/v2"
17 )
18
19 func Options(options *source.Options) {
20         options.LicensesText = licensesText
21         if options.GoDiff {
22                 options.ComputeEdits = ComputeEdits
23         }
24         options.URLRegexp = relaxedFullWord
25         options.GofumptFormat = func(ctx context.Context, src []byte) ([]byte, error) {
26                 return format.Source(src, format.Options{})
27         }
28         updateAnalyzers(options)
29 }
30
31 var relaxedFullWord *regexp.Regexp
32
33 // Ensure links are matched as full words, not anywhere.
34 func init() {
35         relaxedFullWord = regexp.MustCompile(`\b(` + xurls.Relaxed().String() + `)\b`)
36         relaxedFullWord.Longest()
37 }