fix(lsp): improve error completion message #33812

problem: Error notifications from LSP responses were difficult to read due to
inconsistent formatting and missing critical information like client name and error codes.

solution: Implemented a more structured error notification format using pipe separators to
clearly display client name, error code (when available), and error message.

(cherry picked from commit 5c15df449a)
This commit is contained in:
glepnir
2025-05-04 21:40:35 +08:00
committed by github-actions[bot]
parent 47686a1454
commit e512c9589e

View File

@ -506,14 +506,19 @@ local function trigger(bufnr, clients, ctx)
local matches = {}
local server_start_boundary --- @type integer?
for client_id, response in pairs(responses) do
local client = lsp.get_client_by_id(client_id)
if response.err then
vim.notify_once(response.err.message, vim.log.levels.WARN)
local msg = ('%s: %s %s'):format(
client and client.name or 'UNKNOWN',
response.err.code or 'NO_CODE',
response.err.message
)
vim.notify_once(msg, vim.log.levels.WARN)
end
local result = response.result
if result then
Context.isIncomplete = Context.isIncomplete or result.isIncomplete
local client = lsp.get_client_by_id(client_id)
local encoding = client and client.offset_encoding or 'utf-16'
local client_matches
client_matches, server_start_boundary = M._convert_results(