应该不是gopls的问题。
不太清楚怎么折腾lsp-server,但想到可以用strace看看gopls的输出,就去试了一下。
sudo strace -s 65536 -p pid
lsp-server的输出各种东西一股脑的来。但多试几次还是能看到自己的补全项。
发现在lsp-bridge启动的gopls上,标准库中的time确实是补全的第一项,sortText = 0;而"go.starlark.net/lib/time"是第二项,sortText = 1。试了几次均是如此,而补全时却没有标准库的time这一项。
{
"jsonrpc": "2.0",
"result": {
"isIncomplete": true,
"items": [
{
"label": "time",
"kind": 9,
"detail": ""time"",
"preselect": true,
"sortText": "00000",
"filterText": "time",
"insertTextFormat": 2,
"textEdit": {
"range": {
"start": {
"line": 5,
"character": 3
},
"end": {
"line": 5,
"character": 7
}
},
"newText": "time"
},
"additionalTextEdits": [
{
"range": {
"start": {
"line": 1,
"character": 0
},
"end": {
"line": 1,
"character": 0
}
},
"newText": "nimport "time"n"
}
]
},
{
"label": "time",
"kind": 9,
"detail": ""go.starlark.net/lib/time"",
"sortText": "00001",
"filterText": "time",
"insertTextFormat": 2,
"textEdit": {
"range": {
"start": {
"line": 5,
"character": 3
},
"end": {
"line": 5,
"character": 7
}
},
"newText": "time"
},
"additionalTextEdits": [
{
"range": {
"start": {
"line": 1,
"character": 0
},
"end": {
"line": 1,
"character": 0
}
},
"newText": "nimport "go.starlark.net/lib/time"n"
}
]
},
{
"label": "timeformat",
"kind": 9,
"detail": ""golang.org/x/tools/go/analysis/passes/timeformat"",
"sortText": "00002",
"filterText": "timeformat",
"insertTextFormat": 2,
"textEdit": {
"range": {
"start": {
"line": 5,
"character": 3
},
"end": {
"line": 5,
"character": 7
}
},
"newText": "timeformat"
},
"additionalTextEdits": [
{
"range": {
"start": {
"line": 1,
"character": 0
},
"end": {
"line": 1,
"character": 0
}
},
"newText": "nimport "golang.org/x/tools/go/analysis/passes/timeformat"n"
}
]
},
... ...
还挺有意思的,要不是最近太忙了,不然该看看代码解解迷了