update to use conform

This commit is contained in:
kyasuda
2025-08-21 13:51:34 -07:00
parent 714e0ee2ad
commit 9fa25eaf5a
6 changed files with 92 additions and 132 deletions

View File

@@ -17,7 +17,7 @@ end
local spinner_frames = { "", "", "", "", "", "", "", "" }
local function update_spinner(client_id, token)
local function update_spinner(client_id, token, title)
local notif_data = get_notif_data(client_id, token)
if notif_data.spinner then
@@ -28,16 +28,17 @@ local function update_spinner(client_id, token)
hide_from_history = true,
icon = spinner_frames[new_spinner],
replace = notif_data.notification,
title = title,
})
vim.defer_fn(function()
update_spinner(client_id, token)
update_spinner(client_id, token, title)
end, 100)
end
end
local function format_title(title, client_name)
return client_name .. (#title > 0 and ": " .. title or "")
return client_name .. (title and #title > 0 and ": " .. title or "")
end
local function format_message(message, percentage)
@@ -62,23 +63,25 @@ vim.lsp.handlers["$/progress"] = function(_, result, ctx)
local message = format_message(val.message, val.percentage)
notif_data.notification = vim.notify(message, "info", {
title = format_title(val.title, vim.lsp.get_client_by_id(client_id).name),
title = format_title("", vim.lsp.get_client_by_id(client_id).name),
icon = spinner_frames[1],
timeout = false,
hide_from_history = false,
})
notif_data.spinner = 1
update_spinner(client_id, result.token)
update_spinner(client_id, result.token, val.title)
elseif val.kind == "report" and notif_data then
notif_data.notification = vim.notify(format_message(val.message, val.percentage), "info", {
replace = notif_data.notification,
title = format_title("", vim.lsp.get_client_by_id(client_id).name),
hide_from_history = false,
})
elseif val.kind == "end" and notif_data then
notif_data.notification = vim.notify(val.message and format_message(val.message) or "Complete", "info", {
icon = "",
replace = notif_data.notification,
title = format_title("", vim.lsp.get_client_by_id(client_id).name),
timeout = 3000,
})
@@ -95,7 +98,7 @@ vim.lsp.handlers["window/showMessage"] = function(err, result, ctx)
"DEBUG",
})[result.type]
vim.notify("LSP Message: " .. result.message, lvl, {
title = "LSP | " .. client.name,
title = client.name,
timeout = 5000,
keep = function()
return lvl == "ERROR" or lvl == "WARN"