From 8305295d5d6160b862058aa6ec080a7f9160c879 Mon Sep 17 00:00:00 2001 From: Robert Findley Date: Tue, 1 Feb 2022 12:04:17 -0500 Subject: [PATCH] gopls: recognize the go.work file type For golang/go#50930 Change-Id: I5bae56853f1e913fccd559d2a553ced4200bcb35 Reviewed-on: https://go-review.googlesource.com/c/tools/+/382237 Trust: Robert Findley Run-TryBot: Robert Findley Reviewed-by: Hyang-Ah Hana Kim gopls-CI: kokoro TryBot-Result: Gopher Robot --- internal/lsp/cache/view.go | 2 ++ internal/lsp/source/util.go | 4 ++++ internal/lsp/source/view.go | 2 ++ 3 files changed, 8 insertions(+) diff --git a/internal/lsp/cache/view.go b/internal/lsp/cache/view.go index a6a02bfb4f..b2648157cf 100644 --- a/internal/lsp/cache/view.go +++ b/internal/lsp/cache/view.go @@ -247,6 +247,8 @@ func (v *View) FileKind(fh source.FileHandle) source.FileKind { return source.Mod case ".sum": return source.Sum + case ".work": + return source.Work } exts := v.Options().TemplateExtensions for _, ext := range exts { diff --git a/internal/lsp/source/util.go b/internal/lsp/source/util.go index 56974f22d1..a8fb592255 100644 --- a/internal/lsp/source/util.go +++ b/internal/lsp/source/util.go @@ -173,6 +173,8 @@ func FileKindForLang(langID string) FileKind { return Sum case "tmpl", "gotmpl": return Tmpl + case "go.work": + return Work default: return UnknownKind } @@ -188,6 +190,8 @@ func (k FileKind) String() string { return "go.sum" case Tmpl: return "tmpl" + case Work: + return "go.work" default: return fmt.Sprintf("unk%d", k) } diff --git a/internal/lsp/source/view.go b/internal/lsp/source/view.go index d7f4db1a71..08477e1e34 100644 --- a/internal/lsp/source/view.go +++ b/internal/lsp/source/view.go @@ -534,6 +534,8 @@ const ( Sum // Tmpl is a template file. Tmpl + // Work is a go.work file. + Work ) // Analyzer represents a go/analysis analyzer with some boolean properties