Closed lougxing closed 2 years ago
Can you provide more detailed steps to reproduce what you're seeing?
I am using this config"https://github.com/lougxing/dot/blob/master/nvim.d/init.vim"
for example, "https://github.com/nsqio/nsq",
openning nsqadmin/http.go, I input "fmt.", it should be show a list of "functions".
I'm going to need more explicit instructions. When I use autocompletion in https://github.com/nsqio/nsq/blob/master/apps/nsq_tail/nsq_tail.go, it works fine.
system: MacBook Pro (13-inch, M1, 2020)
lougxing:$ brew info nvim
neovim: stable 0.6.1 (bottled), HEAD
lougxing:$ ps -ef|grep gopls
/Users/lougxing/go/bin/gopls serve -listen unix;/var/folders/35/0cvc6v_j2bq7tk2hbwt7r6p40000gn/T/gopls-9c5d3a-daemon.lougxing -listen.timeout 1m0s
lougxing:$ gopls version
golang.org/x/tools/gopls v0.8.0
At first, testing config. It's OK.
1 lougxing:$ mkdir vimgo
2 lougxing:$ cd vimgo/
3 lougxing:$ go mod init vimgo
4 go: creating new go.mod: module vimgo
5 lougxing:$ cat go.mod
6 module vimgo
7
8 go 1.17
9 lougxing:$ nvim hi.go
Input "fmt." , after show all the functions/member of fmt.
1 package main
2
3 import "fmt"
4
5 func main() {
6 | fmt.
7 | fmt Errorf f func(format string, a ...interface{}) error
8 } Formatter t interface{...}
~ Fprint f func(w io.Writer, a ...interface{}) (n int, err error)
~ Fprintf f func(w io.Writer, format string, a ...interface{}) (n int, err error)
~ Fprintln f func(w io.Writer, a ...interface{}) (n int, err error)
~ Fscan f func(r io.Reader, a ...interface{}) (n int, err error)
~ Fscanf f func(r io.Reader, format string, a ...interface{}) (n int, err error)
~ Fscanln f func(r io.Reader, a ...interface{}) (n int, err error)
~ GoStringer t interface{...}
~ Print f func(a ...interface{}) (n int, err error)
~ Printf f func(format string, a ...interface{}) (n int, err error)
~ Println f func(a ...interface{}) (n int, err error)
~ Scan f func(a ...interface{}) (n int, err error)
~ ScanState t interface{...}
~ Scanf f func(format string, a ...interface{}) (n int, err error)
~ Scanln f func(a ...interface{}) (n int, err error)
~ Scanner t interface{...}
~ Sprint f func(a ...interface{}) string
At second,nsq input "fmt" , showing fmt[B], blocking for a long time, It only show Printf and Sprintf.
// nsq infomation,
7 lougxing:$ git branch
8 1 * master
9
10 lougxing:$ git remote -v
11 origin| https://github.com/nsqio/nsq.git (fetch)
12 origin| https://github.com/nsqio/nsq.git (push)
for long long time, blocking
31 func init() {
32
33 | fmt
34 fmt [B]
after blocking, showing
30
31 func init() {
32 | fmt.
33 Printf [M]
34 Sprintf [M]
35
36
37
38
39 | flag.Var(&nsqdTCPAddrs, "nsqd-tcp-address", "nsqd TCP address (may be given multiple times)")
40 | flag.Var(&lookupdHTTPAddrs, "lookupd-http-address", "lookupd HTTP address (may be given multiple times)")
41 | flag.Var(&topics, "topic", "NSQ topic (may be given multiple times)")
42 }
What file are you editing in nsq?
I see you previously said you were editing nsqadmin/http.go
. Completion works fine for me in that file.
Can you execute :let g:go_debug=['lsp']
and then try the completion? I'll need the contents of the __GOLSP_LOG__
window the completion popup appears.
embarrassed, It can't be repeated, all is ok on mac, I do nothing. completing still is fail in my docker,
system: MacBook Pro (13-inch, M1, 2020) starting docker linux(ubuntu:22.04) with platform amd64, It's a amd64 container on arm chip.
docker run -it --platform linux/amd64 -p 127.0.0.1:1022:22 --name build --hostname build.net -v /Users/lougxing/Data:/data -d ubuntu:22.04 /bin/sh
NVIM v0.6.1
Build type: Debug
LuaJIT 2.1.0-beta3
with let g:go_debug=['lsp'], debug message:
{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"2022/04/13 20:16:00 falling back to safe trimming due to type errors: [/usr/local/go/src/runtime/vdso_linux.go:55:38: invalid operation: division by zero /usr/local/go/src/runtime/vdso_linux.go:56:38: invalid operation: division by zero] or still-missing identifiers: map[memRecordCycle:true pageBits:true]\n\tpackage=\"runtime\"\n"}}
===== received =====
Content-Length: 360
{"jsonrpc":"2.0","method":"window/showMessage","params":{"type":4,"message":"gopls requires a module at the root of your workspace. You can work with multiple modules by opening each one as a workspace folder. Improvements to this workflow will be coming soon, and you can learn more here: https://github.com/golang/tools/blob/master/gopls/doc/workspace.md."}}
===== received =====
Content-Length: 463
{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":1,"message":"2022/04/13 20:16:01 errors loading workspace: gopls requires a module at the root of your workspace.\nYou can work with multiple modules by opening each one as a workspace folder.\nImprovements to this workflow will be coming soon, and you can learn more here:\nhttps://github.com/golang/tools/blob/master/gopls/doc/workspace.md.\n\tsnapshot=2\n\tdirectory=file:///data/lougxing\n"}}
===== received =====
Content-Length: 543
{"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///data/lougxing/a.go","version":5,"diagnostics":[{"range":{"start":{"line":0,"character":0},"end":{"line":0,"character":12}},"severity":1,"source":"go list","message":"gopls requires a module at the root of your workspace.\nYou can work with multiple modules by opening each one as a workspace folder.\nImprovements to this workflow will be coming soon, and you can learn more here:\nhttps://github.com/golang/tools/blob/master/gopls/doc/workspace.md."}]}}
Please read those messages that gopls is sending; they describe multiple problems with your environment.
I also don't see any completion requests there. That likely means you didn't attempt completion or that you did so either before enabling the logging or didn't provide the complete contents of the debug log window.
===== sent =====
Content-Length: 677
{"method": "initialize", "jsonrpc": "2.0", "id": 1, "params": {"rootUri": "file:///data/lougxing/xlab/vimgo", "capabilities": {"workspace": {"workspaceFolders": true, "workspaceEdit": {"documentChanges": true}, "configuration": true, "didChangeConfiguration": {"dynamicRegistration": true}}, "textDocument": {"codeAction": {"codeActionLiteralSupport": {"codeActionKind": {"valueSet": ["source.organizeImports", "refactor.rewrite"]}}}, "completion": {"completionItem": {"snippetSupport": false}}, "hover": {"contentFormat": ["plaintext"]}}}, "processId": 48989, "workspaceFolders": [{"uri": "file:///data/lougxing/xlab/vimgo", "name": "/data/lougxing/xlab/vimgo"}]}}
===== stderr =====
serve.go:476: debug server listening at http://localhost:33159
===== received =====
Content-Length: 264
{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"2022/04/15 10:05:53 Handshake session update\n\tupdate_session=1\n\tdebug_address=\"127.0.0.1:33159\"\n\tlogfile=\"\"\n\tserver=\"1\"\n\tgopls_path=\"/data/lougxing/go/bin/gopls\"\n"}}
===== received =====
Content-Length: 3796
{"jsonrpc":"2.0","result":{"capabilities":{"textDocumentSync":{"change":2,"openClose":true,"save":{}},"completionProvider":{"triggerCharacters":["."],"completionItem":{}},"hoverProvider":true,"signatureHelpProvider":{"triggerCharacters":["(",","]},"definitionProvider":true,"typeDefinitionProvider":true,"implementationProvider":true,"referencesProvider":true,"documentHighlightProvider":true,"documentSymbolProvider":true,"codeActionProvider":{"codeActionKinds":["quickfix","refactor.extract","refactor.rewrite","source.fixAll","source.organizeImports"]},"codeLensProvider":{},"documentLinkProvider":{},"workspaceSymbolProvider":true,"documentFormattingProvider":true,"documentOnTypeFormattingProvider":{"firstTriggerCharacter":""},"renameProvider":true,"foldingRangeProvider":true,"executeCommandProvider":{"commands":["gopls.add_dependency","gopls.add_import","gopls.apply_fix","gopls.check_upgrades","gopls.edit_go_directive","gopls.gc_details","gopls.generate","gopls.generate_gopls_mod","gopls.go_get_package","gopls.list_imports","gopls.list_known_packages","gopls.regenerate_cgo","gopls.remove_dependency","gopls.run_tests","gopls.run_vulncheck_exp","gopls.start_debugging","gopls.test","gopls.tidy","gopls.toggle_gc_details","gopls.update_go_sum","gopls.upgrade_dependency","gopls.vendor"]},"callHierarchyProvider":true,"workspace":{"workspaceFolders":{"supported":true,"changeNotifications":"workspace/didChangeWorkspaceFolders"}}},"serverInfo":{"name":"gopls","version":"{\"Path\":\"command-line-arguments\",\"Main\":{\"Path\":\"golang.org/x/tools/gopls\",\"Version\":\"(devel)\",\"Sum\":\"\",\"Replace\":null},\"Deps\":[{\"Path\":\"github.com/BurntSushi/toml\",\"Version\":\"v1.0.0\",\"Sum\":\"h1:dtDWrepsVPfW9H/4y7dDgFc2MBUSeJhlaDtK13CxFlU=\",\"Replace\":null},{\"Path\":\"github.com/google/go-cmp\",\"Version\":\"v0.5.7\",\"Sum\":\"h1:81/ik6ipDQS2aGcBfIN5dHDB36BwrStyeAQquSYCV4o=\",\"Replace\":null},{\"Path\":\"github.com/sergi/go-diff\",\"Version\":\"v1.1.0\",\"Sum\":\"h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=\",\"Replace\":null},{\"Path\":\"golang.org/x/exp/typeparams\",\"Version\":\"v0.0.0-20220218215828-6cf2b201936e\",\"Sum\":\"h1:qyrTQ++p1afMkO4DPEeLGq/3oTsdlvdH4vqZUBWzUKM=\",\"Replace\":null},{\"Path\":\"golang.org/x/mod\",\"Version\":\"v0.6.0-dev.0.20220106191415-9b9b3d81d5e3\",\"Sum\":\"h1:kQgndtyPBW/JIYERgdxfwMYh3AVStj88WQTlNDi2a+o=\",\"Replace\":null},{\"Path\":\"golang.org/x/sync\",\"Version\":\"v0.0.0-20210220032951-036812b2e83c\",\"Sum\":\"h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ=\",\"Replace\":null},{\"Path\":\"golang.org/x/sys\",\"Version\":\"v0.0.0-20220209214540-3681064d5158\",\"Sum\":\"h1:rm+CHSpPEEW2IsXUib1ThaHIjuBVZjxNgSKmBLFfD4c=\",\"Replace\":null},{\"Path\":\"golang.org/x/text\",\"Version\":\"v0.3.7\",\"Sum\":\"h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=\",\"Replace\":null},{\"Path\":\"golang.org/x/tools\",\"Version\":\"v0.1.11-0.20220407163324-91bcfb1bdf9c\",\"Sum\":\"h1:rYiuK/jn6TCxjAq1hQ6MR6pgOeP3A5gIHDxgrQ8Vbys=\",\"Replace\":null},{\"Path\":\"golang.org/x/vuln\",\"Version\":\"v0.0.0-20220324005316-18fd808f5c7f\",\"Sum\":\"h1:9dMzk88fnONra7zrEalqkRMGa9jMGf9B5mdzhYVyI28=\",\"Replace\":null},{\"Path\":\"golang.org/x/xerrors\",\"Version\":\"v0.0.0-20200804184101-5ec99f83aff1\",\"Sum\":\"h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=\",\"Replace\":null},{\"Path\":\"honnef.co/go/tools\",\"Version\":\"v0.3.0\",\"Sum\":\"h1:2LdYUZ7CIxnYgskbUZfY7FPggmqnh6shBqfWa8Tn3XU=\",\"Replace\":null},{\"Path\":\"mvdan.cc/gofumpt\",\"Version\":\"v0.3.0\",\"Sum\":\"h1:kTojdZo9AcEYbQYhGuLf/zszYthRdhDNDUi2JKTxas4=\",\"Replace\":null},{\"Path\":\"mvdan.cc/xurls/v2\",\"Version\":\"v2.4.0\",\"Sum\":\"h1:tzxjVAj+wSBmDcF6zBB7/myTy3gX9xvi8Tyr28AuQgc=\",\"Replace\":null}],\"GoVersion\":\"go1.17.8\",\"Version\":\"v0.8.3\"}"}},"id":1}
===== sent =====
Content-Length: 57
{"method": "initialized", "jsonrpc": "2.0", "params": {}}
===== sent =====
Content-Length: 206
{"method": "workspace/didChangeWorkspaceFolders", "jsonrpc": "2.0", "params": {"event": {"added": [{"uri": "file:///data/lougxing/xlab/vimgo", "name": "/data/lougxing/xlab/vimgo"}], "removed": []}}}
===== sent =====
Content-Length: 259
{"method": "textDocument/didOpen", "jsonrpc": "2.0", "params": {"textDocument": {"uri": "file:///data/lougxing/xlab/vimgo/a.go", "version": 2, "languageId": "go", "text": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tfmt.Println(\"vim-go\")\n}\n"}}}
===== sent =====
Content-Length: 263
{"method": "textDocument/didChange", "jsonrpc": "2.0", "params": {"contentChanges": [{"text": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tfmt.Println(\"vim-go\")\n}\n"}], "textDocument": {"uri": "file:///data/lougxing/xlab/vimgo/a.go", "version": 3}}}
===== received =====
Content-Length: 99
{"jsonrpc":"2.0","method":"window/showMessage","params":{"type":4,"message":"Loading packages..."}}
===== received =====
Content-Length: 150
{"jsonrpc":"2.0","method":"workspace/configuration","params":{"items":[{"scopeUri":"file:///data/lougxing/xlab/vimgo","section":"gopls"}]},"id":1}
===== sent =====
Content-Length: 86
{"id": 1, "jsonrpc": "2.0", "result": [{"buildFlags": [], "hoverKind": "Structured"}]}
===== received =====
Content-Length: 690
{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"2022/04/15 10:05:54 go env for /data/lougxing/xlab/vimgo\n(root /data/lougxing/xlab/vimgo)\n(go version go version go1.17.8 linux/amd64)\n(valid build configuration = true)\n(build flags: [])\nGOPATH=/home/lougxing/go:/data/lougxing/go\nGOPROXY=https://proxy.golang.org,direct\nGO111MODULE=\nGOMODCACHE=/home/lougxing/go/pkg/mod\nGOMOD=/home/lougxing/xlab/vimgo/go.mod\nGOWORK=\nGOINSECURE=\nGOROOT=/usr/local/go\nGOSUMDB=sum.golang.org\nGOFLAGS=\nGOCACHE=/home/lougxing/.cache/go-build\n\n"}}
===== received =====
Content-Length: 217
{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"2022/04/15 10:05:55 go/packages.Load\n\tsnapshot=0\n\tdirectory=/data/lougxing/xlab/vimgo\n\tquery=[builtin vimgo/...]\n\tpackages=2\n"}}
===== received =====
Content-Length: 106
{"jsonrpc":"2.0","method":"window/showMessage","params":{"type":3,"message":"Finished loading packages."}}
===== received =====
Content-Length: 176
{"jsonrpc":"2.0","method":"client/registerCapability","params":{"registrations":[{"id":"workspace/didChangeConfiguration","method":"workspace/didChangeConfiguration"}]},"id":2}
===== sent =====
Content-Length: 43
{"id": 2, "jsonrpc": "2.0", "result": null}
===== received =====
Content-Length: 99
{"jsonrpc":"2.0","method":"window/showMessage","params":{"type":4,"message":"Loading packages..."}}
===== received =====
Content-Length: 150
{"jsonrpc":"2.0","method":"workspace/configuration","params":{"items":[{"scopeUri":"file:///data/lougxing/xlab/vimgo","section":"gopls"}]},"id":3}
===== sent =====
Content-Length: 86
{"id": 3, "jsonrpc": "2.0", "result": [{"buildFlags": [], "hoverKind": "Structured"}]}
===== received =====
Content-Length: 410
{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"2022/04/15 10:05:56 falling back to safe trimming due to type errors: [/usr/local/go/src/runtime/vdso_linux.go:55:38: invalid operation: division by zero /usr/local/go/src/runtime/vdso_linux.go:56:38: invalid operation: division by zero] or still-missing identifiers: map[memRecordCycle:true pageBits:true]\n\tpackage=\"runtime\"\n"}}
===== sent =====
Content-Length: 267
{"method": "textDocument/didChange", "jsonrpc": "2.0", "params": {"contentChanges": [{"text": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tfmt.Println(\"vim-go\")\n\t\n}\n"}], "textDocument": {"uri": "file:///data/lougxing/xlab/vimgo/a.go", "version": 4}}}
===== sent =====
Content-Length: 281
{"method": "textDocument/didChange", "jsonrpc": "2.0", "params": {"contentChanges": [{"text": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tfmt.Println(\"vim-go\")\n\tfmt.Println()\n}\n"}], "textDocument": {"uri": "file:///data/lougxing/xlab/vimgo/a.go", "version": 23}}}
===== sent =====
Content-Length: 285
{"method": "textDocument/didChange", "jsonrpc": "2.0", "params": {"contentChanges": [{"text": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tfmt.Println(\"vim-go\")\n\tfmt.Println(\"\")\n}\n"}], "textDocument": {"uri": "file:///data/lougxing/xlab/vimgo/a.go", "version": 25}}}
===== sent =====
Content-Length: 286
{"method": "textDocument/didChange", "jsonrpc": "2.0", "params": {"contentChanges": [{"text": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tfmt.Println(\"vim-go\")\n\tfmt.Println(\"x\")\n}\n"}], "textDocument": {"uri": "file:///data/lougxing/xlab/vimgo/a.go", "version": 26}}}
===== sent =====
Content-Length: 288
{"method": "textDocument/didChange", "jsonrpc": "2.0", "params": {"contentChanges": [{"text": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tfmt.Println(\"vim-go\")\n\tfmt.Println(\"xxx\")\n}\n"}], "textDocument": {"uri": "file:///data/lougxing/xlab/vimgo/a.go", "version": 34}}}
===== sent =====
Content-Length: 182
{"method": "textDocument/formatting", "jsonrpc": "2.0", "id": 2, "params": {"options": {"insertSpaces": false}, "textDocument": {"uri": "file:///data/lougxing/xlab/vimgo/a.go"}}}
===== received =====
Content-Length: 36
{"jsonrpc":"2.0","result":[],"id":2}
===== sent =====
Content-Length: 280
{"method": "textDocument/codeAction", "jsonrpc": "2.0", "id": 3, "params": {"context": {"only": ["source.organizeImports"]}, "range": {"end": {"character": 0, "line": 8}, "start": {"character": 0, "line": 0}}, "textDocument": {"uri": "file:///data/lougxing/xlab/vimgo/a.go"}}}
===== received =====
Content-Length: 38
{"jsonrpc":"2.0","result":null,"id":3}
===== sent =====
Content-Length: 288
{"method": "textDocument/didChange", "jsonrpc": "2.0", "params": {"contentChanges": [{"text": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tfmt.Println(\"vim-go\")\n\tfmt.Println(\"xxx\")\n}\n"}], "textDocument": {"uri": "file:///data/lougxing/xlab/vimgo/a.go", "version": 35}}}
There don't seem to be any completion requests in that log either. Are you executing :let g:go_debug=['lsp']
before attempting your completion, attempting completion, and then copying the logs?
I find the reason,
in mac init.vim, there is more "au filetype go inoremap
My only attention was focused on this error:
{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"2022/04/13 20:16:00 falling back to safe trimming due to type errors: [/usr/local/go/src/runtime/vdso_linux.go:55:38: invalid operation: division by zero /usr/local/go/src/runtime/vdso_linux.go:56:38: invalid operation: division by zero] or still-missing identifiers: map[memRecordCycle:true pageBits:true]\n\tpackage=\"runtime\"\n"}}
Thank you for your patience and I am very very sorry for my stupidity.
Should we close this then?
fix
What did you do? (required: The issue will be closed when not provided)
if I create a new file named hellloworld.go,after input "fmt.", vim-go can autocomplate. if I open my one file of project (curpath is the path of go.mod), vim-go only autocomplete the words in file, it can't complate std package too. I delete the go.mod, it can complate stdpackage, but still not well for my project.
What did you expect to happen?
I hope it can complate well in my project.
What happened instead?
Configuration (MUST fill this out):
I use nvim. config: Plug 'fatih/vim-go' let g:go_def_mode='gopls' let g:go_info_mode='gopls' au filetype go inoremap . .
vim-go version:
the lastest.
vimrc
you used to reproduce:vimrc
```vim ```Vim version (first three lines from
:version
):NVIM v0.6.1
Go version (
go version
):go version go1.17.6 darwin/arm64
Go environment
go env
Output:gopls version
gopls version
Output: