Giant blob of minor changes
[dotfiles/.git] / .config / coc / extensions / coc-go-data / tools / pkg / mod / golang.org / x / tools / gopls@v0.5.2 / doc / vscode.md
1 # VSCode
2
3 Use the [VSCode-Go] plugin, with the following configuration:
4
5 ```json5
6 "go.useLanguageServer": true,
7 "[go]": {
8     "editor.formatOnSave": true,
9     "editor.codeActionsOnSave": {
10         "source.organizeImports": true,
11     },
12     // Optional: Disable snippets, as they conflict with completion ranking.
13     "editor.snippetSuggestions": "none",
14 },
15 "[go.mod]": {
16     "editor.formatOnSave": true,
17     "editor.codeActionsOnSave": {
18         "source.organizeImports": true,
19     },
20 },
21 "gopls": {
22      // Add parameter placeholders when completing a function.
23     "usePlaceholders": true,
24
25     // If true, enable additional analyses with staticcheck.
26     // Warning: This will significantly increase memory usage.
27     "staticcheck": false,
28 }
29 ```
30
31 VSCode will complain about the `"gopls"` settings, but they will still work. Once we have a consistent set of settings, we will make the changes in the VSCode plugin necessary to remove the errors.
32
33 If you encounter problems with import organization, please try setting a higher code action timeout (any value greater than 750ms), for example:
34
35 ```json5
36 "[go]": {
37   "editor.codeActionsOnSaveTimeout": 3000
38 }
39 ```
40
41 To enable more detailed debug information, add the following to your VSCode settings:
42
43 ```json5
44 "go.languageServerFlags": [
45     "-rpc.trace", // for more detailed debug logging
46     "serve",
47     "--debug=localhost:6060", // to investigate memory usage, see profiles
48 ],
49 ```
50
51 See the section on [command line](command-line.md) arguments for more information about what these do, along with other things like `--logfile=auto` that you might want to use.
52
53 You can disable features through the `"go.languageServerExperimentalFeatures"` section of the config. An example of a feature you may want to disable is `"documentLink"`, which opens [`pkg.go.dev`](https://pkg.go.dev) links when you click on import statements in your file.
54
55 ### Build tags
56
57 build tags will not be picked from `go.buildTags` configuration section, instead they should be specified as part of the`GOFLAGS` environment variable:
58
59 ```json5
60 "go.toolsEnvVars": {
61     "GOFLAGS": "-tags=<yourtag>"
62 }
63 ```
64
65
66 [VSCode-Go]: https://github.com/golang/vscode-go
67
68 # VSCode Remote Development with gopls
69
70 You can also make use of `gopls` with the [VSCode Remote Development](https://code.visualstudio.com/docs/remote/remote-overview) extensions to enable full-featured Go development on a lightweight client machine, while connected to a more powerful server machine.
71
72 First, install the Remote Development extension of your choice, such as the [Remote - SSH](https://code.visualstudio.com/docs/remote/ssh) extension. Once you open a remote session in a new window, open the Extensions pane (Ctrl+Shift+X) and you will see several different sections listed. In the "Local - Installed" section, navigate to the Go extension and click "Install in SSH: hostname".
73
74 Once you have reloaded VSCode, you will be prompted to install `gopls` and other Go-related tools. After one more reload, you should be ready to develop remotely with VSCode and the Go extension.