Skip to content

Commit

Permalink
gopls: add maxUnimportedPackageNames option that makes the number o…
Browse files Browse the repository at this point in the history
…f completion candidates for unimported packages configurable
  • Loading branch information
110y committed Jun 25, 2023
1 parent fa10359 commit d39db52
Show file tree
Hide file tree
Showing 6 changed files with 272 additions and 94 deletions.
6 changes: 6 additions & 0 deletions gopls/doc/settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,12 @@ fields in completion responses.

Default: `false`.

##### **maxUnimportedPackageNames** *int*

max number of completion candidates for unimported packages.

Default: `5`.

##### **completionBudget** *time.Duration*

**This setting is for debugging purposes only.**
Expand Down
1 change: 1 addition & 0 deletions gopls/internal/lsp/protocol/generate/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ func writeserver() {
fmt.Fprintln(out, fileHdr)
out.WriteString(
`import (
"bytes"
"context"
"encoding/json"
Expand Down
4 changes: 3 additions & 1 deletion gopls/internal/lsp/protocol/generate/output.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,9 @@ func genCase(method string, param, result *Type, dir string) {
nm = "ParamConfiguration" // gopls compatibility
}
fmt.Fprintf(out, "\t\tvar params %s\n", nm)
fmt.Fprintf(out, "\t\tif err := json.Unmarshal(r.Params(), &params); err != nil {\n")
fmt.Fprintf(out, "\t\tdecoder := json.NewDecoder(bytes.NewReader(r.Params()))\n")
fmt.Fprintf(out, "\t\tdecoder.UseNumber()\n")
fmt.Fprintf(out, "\t\tif err := decoder.Decode(&params); err != nil {\n")
fmt.Fprintf(out, "\t\t\treturn true, sendParseError(ctx, reply, err)\n\t\t}\n")
p = ", &params"
}
Expand Down

0 comments on commit d39db52

Please sign in to comment.