fix(lsp.completion): add logging for request failures
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user