fix(lsp.completion): add logging for request failures

This commit is contained in:
2026-04-19 00:41:05 +02:00
parent b4721bb444
commit b23fbb3704
3 changed files with 101 additions and 74 deletions
+23 -18
View File
@@ -1,3 +1,4 @@
local log = require("log")
local MAX_WIDTH = 80
local MAX_HEIGHT = 20
local HALF_HEIGHT = math.floor(MAX_HEIGHT / 2)
@@ -114,24 +115,28 @@ end
function Popup:dispatch_resolve(client, item, ft, pum, word, buf)
self:cancel_pending()
self.resolved = nil
local _, request_id = client:request(
vim.lsp.protocol.Methods.completionItem_resolve,
item.raw,
function(err, result)
self.pending = nil
if err or not result then
return
end
local cur = vim.fn.complete_info({ "completed" })
if (vim.tbl_get(cur, "completed", "word") or "") ~= word then
return
end
item:apply_resolved(result)
self.resolved = { word = word, item = item }
self:show(item, ft, pum)
end,
buf
)
local method = vim.lsp.protocol.Methods.completionItem_resolve
local _, request_id = client:request(method, item.raw, function(err, result)
if err then
log.warning(
"client %d: %s failed: %s",
client.id,
method,
err.message
)
end
self.pending = nil
if err or not result then
return
end
local cur = vim.fn.complete_info({ "completed" })
if (vim.tbl_get(cur, "completed", "word") or "") ~= word then
return
end
item:apply_resolved(result)
self.resolved = { word = word, item = item }
self:show(item, ft, pum)
end, buf)
if request_id then
self.pending = { client = client, id = request_id }
end