commit 5c15df449a8772a0ddde3aa42ab67a0bde836939
parent 91e116f3a6719e9dc7652f4e0a4b1760dfbf1af0
Author: glepnir <glephunter@gmail.com>
Date: Sun, 4 May 2025 21:40:35 +0800
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.
Diffstat:
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/runtime/lua/vim/lsp/completion.lua b/runtime/lua/vim/lsp/completion.lua
@@ -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(