fix(lsp.completion): add logging for request failures
This commit is contained in:
+32
-14
@@ -1,5 +1,6 @@
|
||||
local Item = require("lsp.completion.item")
|
||||
local Popup = require("lsp.completion.popup")
|
||||
local log = require("log")
|
||||
local session = require("lsp.completion.session")
|
||||
|
||||
local GROUP = vim.api.nvim_create_augroup("ow.lsp.completion", { clear = true })
|
||||
@@ -113,6 +114,7 @@ function M.setup()
|
||||
return
|
||||
end
|
||||
|
||||
---@param target ow.lsp.completion.Item
|
||||
local function apply(target)
|
||||
local raw = target.raw
|
||||
if raw.additionalTextEdits then
|
||||
@@ -123,10 +125,22 @@ function M.setup()
|
||||
)
|
||||
end
|
||||
if raw.command then
|
||||
client:request("workspace/executeCommand", {
|
||||
local method =
|
||||
vim.lsp.protocol.Methods.workspace_executeCommand
|
||||
client:request(method, {
|
||||
command = raw.command.command,
|
||||
arguments = raw.command.arguments,
|
||||
}, nil, ev.buf)
|
||||
}, function(err)
|
||||
if err then
|
||||
log.warning(
|
||||
"client %d: %s failed for %s: %s",
|
||||
client.id,
|
||||
method,
|
||||
raw.command.title,
|
||||
err.message
|
||||
)
|
||||
end
|
||||
end, ev.buf)
|
||||
end
|
||||
if target.snippet then
|
||||
local word = completed.word or ""
|
||||
@@ -157,18 +171,22 @@ function M.setup()
|
||||
and not item.raw.additionalTextEdits
|
||||
and not item.raw.command
|
||||
then
|
||||
client:request(
|
||||
vim.lsp.protocol.Methods.completionItem_resolve,
|
||||
item.raw,
|
||||
function(err, resolved)
|
||||
if err or not resolved then
|
||||
return
|
||||
end
|
||||
item:apply_resolved(resolved)
|
||||
apply(item)
|
||||
end,
|
||||
ev.buf
|
||||
)
|
||||
local method = vim.lsp.protocol.Methods.completionItem_resolve
|
||||
client:request(method, item.raw, function(err, resolved)
|
||||
if err then
|
||||
log.warning(
|
||||
"client %d: %s failed: %s",
|
||||
client.id,
|
||||
method,
|
||||
err.message
|
||||
)
|
||||
end
|
||||
if err or not resolved then
|
||||
return
|
||||
end
|
||||
item:apply_resolved(resolved)
|
||||
apply(item)
|
||||
end, ev.buf)
|
||||
else
|
||||
apply(item)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user