Closed urandom closed 4 years ago
Can you duplicate the problem you're seeing without all of your other plugins loaded?
Yes, with only the nvim-lsp and vim-go plugins left, the problem is still reproducible.
The documentation you're seeing at the bottom of your screen is enabled by g:go_echo_go_info
, which is enabled by default. Try disabling g:go_echo_go_info
by adding let g:go_echo_go_info=0
in your vimc.
If you don't want to permanently disable that setting, because you want the information, then I'm happy to work with you to figure out why you're seeing more than a single line of info. (hint: I suspect it has something to do with this line in your vimrc:
vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
Ah, excellent, that cleared it off. I'm personally fine with disabling that feature. Though if setting neovim's lsp as an omnifunc really causes a problem, perhaps it would be worth investigating, since I probably won't be the only one doing that.
If you want to see if that was in fact the underlying issue, try removing the line that disables g:go_echo_go_info
and the line that configures neovim's lsp as an omnifunc in your vimrc and see if you you still have the problem. If you don't (you should only see the type info for the chosen autocompletion), then I think g:go_echo_go_info
is sufficient for people.
If you don't care to investigate more, I'm fine with that, too, and we can close this.
Unfortunately, if I remove that line, I won't have omni completion, so there won't be any completion items to test it on.
Vim-go can use gopls
for completion if you'll remove let g:go_gopls_enabled = 0
from your vimrc.
So, after bringing init.vim to a bare minimum, with only vim-go enabled with its default settings, the behavior is still reproducible.
🤔 That's interesting.
Can you run it again with only vim-go enabled with its default settings and add let g:go_debug = ['lsp']
to your vimrc and then provide the gopls output here?
This is everything in the log buffer:
===== sent ===== Content-Length: 672 {"method": "initialize", "jsonrpc": "2.0", "id": 1, "params": {"rootUri": "file:///Users/user/projects/feature-toggles", "capabilities": {"workspace": {"workspaceFolders": true, "configuration": true, "didChangeConfiguration": {"dynamicRegistration": true}}, "textDocument": {"codeAction": {"codeActionLiteralSupport": {"codeActionKind": {"valueSet": ["source.organizeImports"]}}}, "completion": {"completionItem": {"snippetSupport": false}}, "hover": {"contentFormat": ["plaintext"]}}}, "processId": 4590, "workspaceFolders": [{"uri": "file:///Users/user/projects/feature-toggles", "name": "/Users/user/projects/feature-toggles"}]}} ===== stderr ===== 2020/06/03 22:58:44 debug server listening on port 53266 ===== received ===== Content-Length: 923 {"jsonrpc":"2.0","result":{"capabilities":{"textDocumentSync":{"openClose":true,"change":2,"save":{}},"completionProvider":{"triggerCharacters":["."]},"hoverProvider":true,"signatureHelpProvider":{"triggerCharacters":["(",","]},"definitionProvider":true,"typeDefinitionProvider":true,"implementationProvider":true,"referencesProvider":true,"documentHighlightProvider":true,"documentSymbolProvider":true,"codeActionProvider":{"codeActionKinds":["quickfix","source.organizeImports"]},"codeLensProvider":{},"documentLinkProvider":{},"workspaceSymbolProvider":true,"documentFormattingProvider":true,"documentOnTypeFormattingProvider":{"firstTriggerCharacter":""},"renameProvider":true,"foldingRangeProvider":true,"executeCommandProvider":{"commands":["tidy","upgrade.dependency"]},"workspace":{"workspaceFolders":{"supported":true,"changeNotifications":"workspace/didChangeWorkspaceFolders"}}},"serverInfo":{"name":""}},"id":1} ===== sent ===== Content-Length: 57 {"method": "initialized", "jsonrpc": "2.0", "params": {}} ===== sent ===== Content-Length: 1799 {"method": "textDocument/didOpen", "jsonrpc": "2.0", "params": {"textDocument": {"uri": "file:///Users/user/projects/feature-toggles/messaging/nats.go", "version": 1, "languageId": "go", "text": "package messaging\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"time\"\n\n\t\"github.com/globusdigital/feature-toggles/toggle\"\n\t\"github.com/nats-io/nats.go\"\n)\n\nconst (\n\tDefaultNatsReconnectBufSize = 16 * 1024 * 1024\n\tDefaultNatsPingInterval = time.Minute\n\tNatsSubject = \"feature-toggles\"\n)\n\ntype Nats struct {\n\tConn *nats.EncodedConn\n}\n\nfunc NewNats(url string, opts ...nats.Option) (Nats, error) {\n\tconn, err := nats.Connect(url, opts...)\n\tif err != nil {\n\t\treturn Nats{}, fmt.Errorf(\"connecting to NATS: %w\", err)\n\t}\n\n\tencoded, err := nats.NewEncodedConn(conn, nats.JSON_ENCODER)\n\tif err != nil {\n\t\treturn Nats{}, fmt.Errorf(\"creating json encoded connection: %v\", err)\n\t}\n\n\treturn Nats{encoded}, nil\n}\n\nfunc (b Nats) Close() {\n\tb.Conn.Close()\n}\n\nfunc (b Nats) Send(ctx context.Context, event toggle.Event) error {\n\tif ctx.Err() != nil {\n\t\treturn ctx.Err()\n\t}\n\n\tif err := b.Conn.Publish(NatsSubject, event); err != nil {\n\t\treturn fmt.Errorf(\"publishing event: %v\", err)\n\t}\n\n\treturn nil\n}\n\nfunc (s Nats) Receiver(ctx context.Context) <-chan toggle.Event {\n\tch := make(chan toggle.Event)\n\tgo func() {\n\t\tdefer close(ch)\n\n\t\tsub, err := s.Conn.Subscribe(NatsSubject, func(ev toggle.Event) {\n\t\t\tch <- ev\n\t\t})\n\t\tif err != nil {\n\t\t\tch <- toggle.Event{Type: toggle.ErrorEvent, Error: \"subscribing to nats subject: \" + err.Error()}\n\t\t\treturn\n\t\t}\n\t\tdefer sub.Unsubscribe()\n\n\t\tselect {\n\t\tcase <-ctx.Done():\n\t\t\treturn\n\t\t}\n\t}()\n\n\treturn ch\n}\n"}}} ===== received ===== Content-Length: 268 {"jsonrpc":"2.0","method":"client/registerCapability","params":{"registrations":[{"id":"workspace/didChangeConfiguration","method":"workspace/didChangeConfiguration"},{"id":"workspace/didChangeWorkspaceFolders","method":"workspace/didChangeWorkspaceFolders"}]},"id":1} ===== sent ===== Content-Length: 43 {"id": 1, "jsonrpc": "2.0", "result": null} ===== received ===== Content-Length: 310 {"jsonrpc":"2.0","method":"workspace/configuration","params":{"items":[{"scopeUri":"file:///Users/user/projects/feature-toggles","section":"gopls"},{"scopeUri":"file:///Users/user/projects/feature-toggles","section":"gopls-/Users/user/projects/feature-toggles"}]},"id":2} ===== sent ===== Content-Length: 133 {"id": 2, "jsonrpc": "2.0", "result": [{"buildFlags": [], "hoverKind": "Structured"}, {"buildFlags": [], "hoverKind": "Structured"}]} ===== received ===== Content-Length: 2157 {"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"2020/06/03 22:58:44 Build info\n----------\ngolang.org/x/tools/gopls v0.3.3\n golang.org/x/tools/gopls@v0.3.3 h1:mTFqRDJQmpSsgDDWvbtGnSva1z9uX2XcDszSWa6DhBQ=\n github.com/BurntSushi/toml@v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=\n github.com/sergi/go-diff@v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ=\n golang.org/x/mod@v0.1.1-0.20191105210325-c90efee705ee h1:WG0RUwxtNT4qqaXX3DPA8zHFNm/D9xaBpxzHt1WcA/E=\n golang.org/x/sync@v0.0.0-20190423024810-112230192c58 h1:8gQV6CLnAEikrhgkHFbMAEhagSSnXWGV915qUMm9mrU=\n golang.org/x/tools@v0.0.0-20200227200655-6862ededa516 h1:OX66ZzpltgCOuBSGdaeT77hS2z3ub2AB+EuGxvGRBLE=\n golang.org/x/xerrors@v0.0.0-20191011141410-1b5146add898 h1:/atklqdjdhuosWIl6AIbOeHJjicWYPqR9bpxqxYG2pA=\n honnef.co/go/tools@v0.0.1-2020.1.3 h1:sXmLre5bzIR6ypkjXCDI3jHPssRhc8KD/Ome589sc3U=\n mvdan.cc/xurls/v2@v2.1.0 h1:KaMb5GLhlcSX+e+qhbRJODnUUBvlw01jt4yrjFIHAuA=\n\nGo info\n-------\ngo version go1.14.3 darwin/amd64\n\nGO111MODULE=\"\"\nGOARCH=\"amd64\"\nGOBIN=\"\"\nGOCACHE=\"/Users/user/Library/Caches/go-build\"\nGOENV=\"/Users/user/Library/Application Support/go/env\"\nGOEXE=\"\"\nGOFLAGS=\"\"\nGOHOSTARCH=\"amd64\"\nGOHOSTOS=\"darwin\"\nGOINSECURE=\"\"\nGONOPROXY=\"\"\nGONOSUMDB=\"\"\nGOOS=\"darwin\"\nGOPATH=\"/Users/user/go\"\nGOPRIVATE=\"\"\nGOPROXY=\"https://proxy.golang.org,direct\"\nGOROOT=\"/usr/local/Cellar/go/1.14.3/libexec\"\nGOSUMDB=\"sum.golang.org\"\nGOTMPDIR=\"\"\nGOTOOLDIR=\"/usr/local/Cellar/go/1.14.3/libexec/pkg/tool/darwin_amd64\"\nGCCGO=\"gccgo\"\nAR=\"ar\"\nCC=\"clang\"\nCXX=\"clang++\"\nCGO_ENABLED=\"0\"\nGOMOD=\"/Users/user/projects/feature-toggles/go.mod\"\nCGO_CFLAGS=\"-g -O2\"\nCGO_CPPFLAGS=\"\"\nCGO_CXXFLAGS=\"-g -O2\"\nCGO_FFLAGS=\"-g -O2\"\nCGO_LDFLAGS=\"-g -O2\"\nPKG_CONFIG=\"pkg-config\"\nGOGCCFLAGS=\"-fPIC -m64 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/ky/99mqlqrd2rd46chcz3tqmxkw0000gn/T/go-build146176517=/tmp/go-build -gno-record-gcc-switches -fno-common\"\n"}} ===== received ===== Content-Length: 175 {"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"2020/06/03 22:58:44 go/packages.Load\n\tsnapshot = 0\n\tquery = [./... builtin]\n\tpackages = 15"}} ===== sent ===== Content-Length: 1812 {"method": "textDocument/didChange", "jsonrpc": "2.0", "params": {"contentChanges": [{"text": "package messaging\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"time\"\n\n\t\"github.com/globusdigital/feature-toggles/toggle\"\n\t\"github.com/nats-io/nats.go\"\n)\n\nconst (\n\tDefaultNatsReconnectBufSize = 16 * 1024 * 1024\n\tDefaultNatsPingInterval = time.Minute\n\tNatsSubject = \"feature-toggles\"\n)\n\ntype Nats struct {\n\tConn *nats.EncodedConn\n}\n\nfunc NewNats(url string, opts ...nats.Option) (Nats, error) {\n\tconn, err := nats.Connect(url, opts...)\n\tif err != nil {\n\t\treturn Nats{}, fmt.Errorf(\"connecting to NATS: %w\", err)\n\t}\n\tconn.\n\n\tencoded, err := nats.NewEncodedConn(conn, nats.JSON_ENCODER)\n\tif err != nil {\n\t\treturn Nats{}, fmt.Errorf(\"creating json encoded connection: %v\", err)\n\t}\n\n\treturn Nats{encoded}, nil\n}\n\nfunc (b Nats) Close() {\n\tb.Conn.Close()\n}\n\nfunc (b Nats) Send(ctx context.Context, event toggle.Event) error {\n\tif ctx.Err() != nil {\n\t\treturn ctx.Err()\n\t}\n\n\tif err := b.Conn.Publish(NatsSubject, event); err != nil {\n\t\treturn fmt.Errorf(\"publishing event: %v\", err)\n\t}\n\n\treturn nil\n}\n\nfunc (s Nats) Receiver(ctx context.Context) <-chan toggle.Event {\n\tch := make(chan toggle.Event)\n\tgo func() {\n\t\tdefer close(ch)\n\n\t\tsub, err := s.Conn.Subscribe(NatsSubject, func(ev toggle.Event) {\n\t\t\tch <- ev\n\t\t})\n\t\tif err != nil {\n\t\t\tch <- toggle.Event{Type: toggle.ErrorEvent, Error: \"subscribing to nats subject: \" + err.Error()}\n\t\t\treturn\n\t\t}\n\t\tdefer sub.Unsubscribe()\n\n\t\tselect {\n\t\tcase <-ctx.Done():\n\t\t\treturn\n\t\t}\n\t}()\n\n\treturn ch\n}\n"}], "textDocument": {"uri": "file:///Users/user/projects/feature-toggles/messaging/nats.go", "version": 2}}} ===== sent ===== Content-Length: 221 {"method": "textDocument/completion", "jsonrpc": "2.0", "id": 2, "params": {"textDocument": {"uri": "file:///Users/user/projects/feature-toggles/messaging/nats.go"}, "position": {"character": 6, "line": 26}}} ===== received ===== Content-Length: 342 {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///Users/user/projects/feature-toggles/messaging/nats.go","version":2,"diagnostics":[{"range":{"start":{"line":26,"character":1},"end":{"line":26,"character":1}},"severity":1,"source":"syntax","message":"expected identifier on left side of :="}]}}
The response to the textDocument/completion
request is missing, but that's what I really need. 🤔
No idea, I tried it again, but the response is still not there.
Maybe do another operation after completion (e.g. do completion again or jump to a definition) to see if it's a previously undiscovered buffering issue...
I also have similar issue where vim-go is not completing the parens ()
after I hit enter, I get the method name but not ()
.
Some more context - https://gophers.slack.com/archives/C07GBR52P/p1591278654374600
@varun06 that doesn't sound similar to this at all other than completion is involved. Please open a new issue if you need help with it.
@urandom should we close this or keep it open and keep digging in? I'm up for whatever works for you
@bhcleek It seems that no matter how many times I invoke the omni completion, the response is never printed in that logging buffer
This is the completion response when I use my original init.vim and start gopls with rpc.trace myself:
[Trace - 10:54:51.576 AM] Received response 'textDocument/completion - (3)' in 47ms. Result: {"isIncomplete":true,"items":[{"label":"html","kind":9,"detail":"\"html\"","preselect":true,"sortText":"00000","filterText":"html","insertTextFormat":2,"textEdit":{"range":{"start":{"line":6,"character":1},"end":{"line":6,"character":3}},"newText":"html"},"additionalTextEdits":[{"range":{"start":{"line":2,"character":7},"end":{"line":2,"character":7}},"newText":"(\n\t"},{"range":{"start":{"line":3,"character":0},"end":{"line":3,"character":0}},"newText":"\t\"html\"\n)\n"}]},{"label":"http","kind":9,"detail":"\"net/http\"","sortText":"00001","filterText":"html","insertTextFormat":2,"textEdit":{"range":{"start":{"line":6,"character":1},"end":{"line":6,"character":3}},"newText":"http"},"additionalTextEdits":[{"range":{"start":{"line":2,"character":7},"end":{"line":2,"character":7}},"newText":"(\n\t"},{"range":{"start":{"line":3,"character":0},"end":{"line":3,"character":0}},"newText":"\t\"net/http\"\n)\n"}]},{"label":"httptest","kind":9,"detail":"\"net/http/httptest\"","sortText":"00002","filterText":"html","insertTextFormat":2,"textEdit":{"range":{"start":{"line":6,"character":1},"end":{"line":6,"character":3}},"newText":"httptest"},"additionalTextEdits":[{"range":{"start":{"line":2,"character":7},"end":{"line":2,"character":7}},"newText":"(\n\t"},{"range":{"start":{"line":3,"character":0},"end":{"line":3,"character":0}},"newText":"\t\"net/http/httptest\"\n)\n"}]},{"label":"httptrace","kind":9,"detail":"\"net/http/httptrace\"","sortText":"00003","filterText":"html","insertTextFormat":2,"textEdit":{"range":{"start":{"line":6,"character":1},"end":{"line":6,"character":3}},"newText":"httptrace"},"additionalTextEdits":[{"range":{"start":{"line":2,"character":7},"end":{"line":2,"character":7}},"newText":"(\n\t"},{"range":{"start":{"line":3,"character":0},"end":{"line":3,"character":0}},"newText":"\t\"net/http/httptrace\"\n)\n"}]},{"label":"httputil","kind":9,"detail":"\"net/http/httputil\"","sortText":"00004","filterText":"html","insertTextFormat":2,"textEdit":{"range":{"start":{"line":6,"character":1},"end":{"line":6,"character":3}},"newText":"httputil"},"additionalTextEdits":[{"range":{"start":{"line":2,"character":7},"end":{"line":2,"character":7}},"newText":"(\n\t"},{"range":{"start":{"line":3,"character":0},"end":{"line":3,"character":0}},"newText":"\t\"net/http/httputil\"\n)\n"}]}]}
I assume it should be the same as with the bare one with only vim-go
That's really weird. My debug log always contains those responses 🤔
In any case, I'm finally able to duplicate your original issue. It seems to be specific to Neovim. I'll get a fix out as soon as I can.
I can duplicate this in Vim now, too.
@urandom #2907 should resolve this for you. Do you want to give it a try before I merge?
The reason I was having a hard time duplicating is that it seems that when UltiSnips is used too, it manages to hide the command-line output that vim-go writes when g:go_echo_go_info
is enabled, so I wasn't seeing the problem that you were experiencing.
What did you do? (required: The issue will be closed when not provided)
Pressing after selecting a completion item from the omni menu
What did you expect to happen?
I expected vim-go to not take any part in that workflow.
What happened instead?
The following message will be printed in the command line, expanding it to at least 4 lines, even if only one line is being occupied.
This steals the focus and exits insert mode.
Configuration (MUST fill this out):
vim-go version:
9d76bb0
vimrc
you used to reproduce:vimrc
Vim version (first three lines from
:version
):