internal/lsp: add unnecessary tags for unused vars and imports

Diagnostic Tags add another hint for the client for how to
display diagnostics. The Unnecessary tags allows clients to
fade out the diagnostic instead of adding a squiggle. This adds
this tag to unused import errors as well as unused vars.

For golang/vscode-go#2285

Change-Id: I0c93b28a6a2ef4eed314dcf30a37c27dd65940ac
Reviewed-on: https://go-review.googlesource.com/c/tools/+/415499
Reviewed-by: Robert Findley <rfindley@google.com>
diff --git a/internal/lsp/cache/errors.go b/internal/lsp/cache/errors.go
index a1aecb3..80ae545 100644
--- a/internal/lsp/cache/errors.go
+++ b/internal/lsp/cache/errors.go
@@ -123,6 +123,10 @@
 		diag.Code = code.String()
 		diag.CodeHref = typesCodeHref(snapshot, code)
 	}
+	switch code {
+	case typesinternal.UnusedVar, typesinternal.UnusedImport:
+		diag.Tags = append(diag.Tags, protocol.Unnecessary)
+	}
 
 	for _, secondary := range e.secondaries {
 		_, secondarySpan, err := typeErrorData(snapshot.FileSet(), pkg, secondary)