refactor(lsp): tidy up logging

This commit is contained in:
Lewis Russell
2024-02-08 09:24:47 +00:00
committed by Lewis Russell
parent 2a7c4aca42
commit 1f9da3d083
8 changed files with 152 additions and 198 deletions

View File

@@ -413,9 +413,7 @@ M[ms.textDocument_hover] = M.hover
---(`textDocument/definition` can return `Location` or `Location[]`
local function location_handler(_, result, ctx, config)
if result == nil or vim.tbl_isempty(result) then
if log.info() then
log.info(ctx.method, 'No location found')
end
log.info(ctx.method, 'No location found')
return nil
end
local client = assert(vim.lsp.get_client_by_id(ctx.client_id))
@@ -649,13 +647,14 @@ end
-- Add boilerplate error validation and logging for all of these.
for k, fn in pairs(M) do
M[k] = function(err, result, ctx, config)
local _ = log.trace()
and log.trace('default_handler', ctx.method, {
if log.trace() then
log.trace('default_handler', ctx.method, {
err = err,
result = result,
ctx = vim.inspect(ctx),
config = config,
})
end
if err then
-- LSP spec: