New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
x/tools/cmd/gopls: goimport and gofmt do not execute on save #33089
Comments
Have you configured your settings according to https://github.com/golang/go/wiki/gopls? In particular, "[go]": {
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports": true
}
}, |
This is the contents of my settings.json
{
"editor.minimap.enabled": false,
"go.autocompleteUnimportedPackages": true,
"go.gocodeAutoBuild": true,
"files.autoSave": "afterDelay",
"[go]": {
"editor.snippetSuggestions": "none",
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports": true
}
},
"gopls": {
"usePlaceholders": true // add parameter placeholders when
completing a function
},
"files.eol": "\n", // formatting only supports LF line endings
}
…On Sun, Jul 14, 2019 at 2:47 PM Rebecca Stambler ***@***.***> wrote:
Have you configured your settings according to
https://github.com/golang/go/wiki/gopls? In particular,
"[go]": {
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports": true
}
},
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#33089?email_source=notifications&email_token=AACHUD43U7LUI4LFVN4FNDTP7NYCRA5CNFSM4ICRKP4KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZ4LBQI#issuecomment-511226049>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AACHUDYYEMTS6VZRBV2DYI3P7NYCRANCNFSM4ICRKP4A>
.
--
Bob Hancock
|
Do the other features work for you? Does formatting work if you right-click and "Format Document"? Can you share a |
I changed settings.json to start the server with debug data.
{
"editor.minimap.enabled": false,
"go.autocompleteUnimportedPackages": true,
"go.gocodeAutoBuild": true,
"files.autoSave": "afterDelay",
"[go]": {
"editor.snippetSuggestions": "none",
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports": true
}
},
"gopls": {
"usePlaceholders": true // add parameter placeholders when
completing a function
},
"files.eol": "\n",
"go.useLanguageServer": true, // formatting only supports LF line
endings
"go.languageServerFlags": [
"-rpc.trace", // for more detailed debug logging
"serve",
"--debug=localhost:6060", // to investigate memory usage, see
profiles
],
}
- Restarted vscode.
- Right click - Reformat document and the formatting works.
[Trace - 6:06:34 PM] Received response 'textDocument/codeAction - (15)' in
0ms.
Params: [{"title":"Organize
Imports","kind":"source.organizeImports","edit":{"changes":{"file:///home/rwh/go/src/goxmeans/km_test.go":[]}}}]
[Trace - 6:06:34 PM] Sending notification 'textDocument/codeAction' in 28ms.
Params:
{"textDocument":{"uri":"file:///home/rwh/go/src/goxmeans/km_test.go"},"range":{"start":{"line":8,"character":10},"end":{"line":8,"character":10}},"context":{"diagnostics":[]}}
[Trace - 6:06:36 PM] Received response 'textDocument/formatting - (16)' in
0ms.
Params: []
[Trace - 6:06:36 PM] Sending notification 'textDocument/formatting' in 31ms.
Params:
{"textDocument":{"uri":"file:///home/rwh/go/src/goxmeans/km_test.go"},"options":{"tabSize":4,"insertSpaces":false}}
…On Sun, Jul 14, 2019 at 5:35 PM Rebecca Stambler ***@***.***> wrote:
Do the other features work for you? Does formatting work if you
right-click and "Format Document"? Can you share a gopls log? See
https://github.com/golang/go/wiki/gopls#troubleshooting.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#33089?email_source=notifications&email_token=AACHUD3UQBYFKDI7DDGG6BTP7OL2DA5CNFSM4ICRKP4KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZ4NX5I#issuecomment-511237109>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AACHUD3HKPOGVHGRKAMYK5DP7OL2DANCNFSM4ICRKP4A>
.
--
Bob Hancock
|
Can you share a log from when you save and expect "[go]": {
"editor.codeActionsOnSaveTimeout": 3000
} to increase the timeout for |
- I add the entry to settings.json.
- I deleted "fmt" from my import statements.
- Saved the fiel.
- The import was not inserted.
[Trace - 6:21:06 PM] Received response 'textDocument/codeAction - (9)' in
0ms.
Params: [{"title":"Organize
Imports","kind":"source.organizeImports","edit":{"changes":{"file:///home/rwh/go/src/goxmeans/km_test.go":[{"range":{"start":{"line":4,"character":0},"end":{"line":4,"character":0}},"newText":"\t\"fmt\"\n"}]}}}]
[Trace - 6:21:06 PM] Sending notification 'textDocument/codeAction' in 28ms.
Params:
{"textDocument":{"uri":"file:///home/rwh/go/src/goxmeans/km_test.go"},"range":{"start":{"line":5,"character":4},"end":{"line":5,"character":4}},"context":{"diagnostics":[]}}
…On Sun, Jul 14, 2019 at 6:17 PM Rebecca Stambler ***@***.***> wrote:
Can you share a log from when you save and expect goimports to work? Note
that you can set
"[go]": {
"editor.codeActionsOnSaveTimeout": 3000
}
to increase the timeout for goimports, which may solve your problem.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#33089?email_source=notifications&email_token=AACHUD37NBGIWI6A3MKA6X3P7OQXZA5CNFSM4ICRKP4KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZ4ONBA#issuecomment-511239812>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AACHUD6ZQNCYYBI64FPID5LP7OQXZANCNFSM4ICRKP4A>
.
--
Bob Hancock
|
Based on these log messages, it seems like the response coming from |
Thanks for the insight and rapid replies. I'll open an appropriate but at
one of the two VSCode site.
…On Sun, Jul 14, 2019 at 7:01 PM Rebecca Stambler ***@***.***> wrote:
Based on these log messages, it seems like the response coming from gopls
is correct. See the "newText" field of the response, which adds "fmt".
This doesn't seem to be a gopls issue, but rather something to do with
VSCode. It may be worth opening an issue with
https://github.com/microsoft/vscode-go or
https://github.com/microsoft/vscode-languageserver-node.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#33089?email_source=notifications&email_token=AACHUD5FEDNCJQ55IVCKYVDP7OV3RA5CNFSM4ICRKP4KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZ4PABA#issuecomment-511242244>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AACHUD57Y35KSYUNDLLGGSDP7OV3RANCNFSM4ICRKP4A>
.
--
Bob Hancock
|
What version of Go are you using (
go version
)?1.12.5
Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (
go env
)?Linu
What did you do?
The text was updated successfully, but these errors were encountered: