| 1 |
Execute a gopls custom LSP command |
| 2 |
|
| 3 |
Usage: |
| 4 |
gopls [flags] execute [flags] command argument... |
| 5 |
|
| 6 |
The execute command sends an LSP ExecuteCommand request to gopls, |
| 7 |
with a set of optional JSON argument values. |
| 8 |
Some commands return a result, also JSON. |
| 9 |
|
| 10 |
Gopls' command set is defined by the command.Interface type; see |
| 11 |
https://pkg.go.dev/golang.org/x/tools/gopls/internal/protocol/command#Interface. |
| 12 |
It is not a stable interface: commands may change or disappear without notice. |
| 13 |
|
| 14 |
Examples: |
| 15 |
|
| 16 |
$ gopls execute gopls.add_import '{"ImportPath": "fmt", "URI": "file:///hello.go"}' |
| 17 |
$ gopls execute gopls.run_tests '{"URI": "file:///a_test.go", "Tests": ["Test"]}' |
| 18 |
$ gopls execute gopls.list_known_packages '{"URI": "file:///hello.go"}' |
| 19 |
|
| 20 |
execute-flags: |
| 21 |
-d,-diff |
| 22 |
display diffs instead of edited file content |
| 23 |
-l,-list |
| 24 |
display names of edited files |
| 25 |
-preserve |
| 26 |
with -write, make copies of original files |
| 27 |
-w,-write |
| 28 |
write edited content to source files |