mirror of
https://git.aramjonghu.dev/AramJonghu/nvim.git
synced 2026-09-01 07:33:31 +02:00
stylua added rule
This commit is contained in:
+55
-33
@@ -26,9 +26,7 @@ require("notify").setup {
|
||||
local client_notifs = {}
|
||||
|
||||
local function get_notif_data(client_id, token)
|
||||
if not client_notifs[client_id] then
|
||||
client_notifs[client_id] = {}
|
||||
end
|
||||
if not client_notifs[client_id] then client_notifs[client_id] = {} end
|
||||
|
||||
if not client_notifs[client_id][token] then
|
||||
client_notifs[client_id][token] = {}
|
||||
@@ -37,7 +35,8 @@ local function get_notif_data(client_id, token)
|
||||
return client_notifs[client_id][token]
|
||||
end
|
||||
|
||||
local spinner_frames = { "⣾", "⣽", "⣻", "⢿", "⡿", "⣟", "⣯", "⣷" }
|
||||
local spinner_frames =
|
||||
{ "⣾", "⣽", "⣻", "⢿", "⡿", "⣟", "⣯", "⣷" }
|
||||
|
||||
local function update_spinner(client_id, token)
|
||||
local notif_data = get_notif_data(client_id, token)
|
||||
@@ -52,9 +51,7 @@ local function update_spinner(client_id, token)
|
||||
replace = notif_data.notification,
|
||||
})
|
||||
|
||||
vim.defer_fn(function()
|
||||
update_spinner(client_id, token)
|
||||
end, 100)
|
||||
vim.defer_fn(function() update_spinner(client_id, token) end, 100)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -74,9 +71,7 @@ vim.lsp.handlers["$/progress"] = function(_, result, ctx)
|
||||
|
||||
local val = result.value
|
||||
|
||||
if not val.kind then
|
||||
return
|
||||
end
|
||||
if not val.kind then return end
|
||||
|
||||
local notif_data = get_notif_data(client_id, result.token)
|
||||
|
||||
@@ -84,7 +79,10 @@ 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(
|
||||
val.title,
|
||||
vim.lsp.get_client_by_id(client_id).name
|
||||
),
|
||||
icon = spinner_frames[1],
|
||||
timeout = false,
|
||||
hide_from_history = false,
|
||||
@@ -93,16 +91,21 @@ vim.lsp.handlers["$/progress"] = function(_, result, ctx)
|
||||
notif_data.spinner = 1
|
||||
update_spinner(client_id, result.token)
|
||||
elseif val.kind == "report" and notif_data then
|
||||
notif_data.notification = vim.notify(format_message(val.message, val.percentage), "info", {
|
||||
replace = notif_data.notification,
|
||||
hide_from_history = false,
|
||||
})
|
||||
notif_data.notification =
|
||||
vim.notify(format_message(val.message, val.percentage), "info", {
|
||||
replace = notif_data.notification,
|
||||
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,
|
||||
timeout = 6000,
|
||||
})
|
||||
notif_data.notification = vim.notify(
|
||||
val.message and format_message(val.message) or "Complete",
|
||||
"info",
|
||||
{
|
||||
icon = "",
|
||||
replace = notif_data.notification,
|
||||
timeout = 6000,
|
||||
}
|
||||
)
|
||||
|
||||
notif_data.spinner = nil
|
||||
end
|
||||
@@ -111,14 +114,22 @@ end
|
||||
-- table from lsp severity to vim severity.
|
||||
local severity = { "error", "warn", "info" }
|
||||
|
||||
vim.lsp.handlers["window/showMessage"] = function(err, method, params, client_id)
|
||||
vim.lsp.handlers["window/showMessage"] = function(
|
||||
err,
|
||||
method,
|
||||
params,
|
||||
client_id
|
||||
)
|
||||
vim.notify(method.message, severity[params.type])
|
||||
end
|
||||
|
||||
-- DAP integration
|
||||
-- Make sure to also have the snippet with the common helper functions in your config!
|
||||
|
||||
dap.listeners.before["event_progressStart"]["progress-notifications"] = function(session, body)
|
||||
dap.listeners.before["event_progressStart"]["progress-notifications"] = function(
|
||||
session,
|
||||
body
|
||||
)
|
||||
local notif_data = get_notif_data("dap", body.progressId)
|
||||
|
||||
local message = format_message(body.message, body.percentage)
|
||||
@@ -132,20 +143,31 @@ dap.listeners.before["event_progressStart"]["progress-notifications"] = function
|
||||
notif_data.notification.spinner = 1, update_spinner("dap", body.progressId)
|
||||
end
|
||||
|
||||
dap.listeners.before["event_progressUpdate"]["progress-notifications"] = function(session, body)
|
||||
dap.listeners.before["event_progressUpdate"]["progress-notifications"] = function(
|
||||
session,
|
||||
body
|
||||
)
|
||||
local notif_data = get_notif_data("dap", body.progressId)
|
||||
notif_data.notification = vim.notify(format_message(body.message, body.percentage), "info", {
|
||||
replace = notif_data.notification,
|
||||
hide_from_history = false,
|
||||
})
|
||||
notif_data.notification =
|
||||
vim.notify(format_message(body.message, body.percentage), "info", {
|
||||
replace = notif_data.notification,
|
||||
hide_from_history = false,
|
||||
})
|
||||
end
|
||||
|
||||
dap.listeners.before["event_progressEnd"]["progress-notifications"] = function(session, body)
|
||||
dap.listeners.before["event_progressEnd"]["progress-notifications"] = function(
|
||||
session,
|
||||
body
|
||||
)
|
||||
local notif_data = client_notifs["dap"][body.progressId]
|
||||
notif_data.notification = vim.notify(body.message and format_message(body.message) or "Complete", "info", {
|
||||
icon = "",
|
||||
replace = notif_data.notification,
|
||||
timeout = 6000,
|
||||
})
|
||||
notif_data.notification = vim.notify(
|
||||
body.message and format_message(body.message) or "Complete",
|
||||
"info",
|
||||
{
|
||||
icon = "",
|
||||
replace = notif_data.notification,
|
||||
timeout = 6000,
|
||||
}
|
||||
)
|
||||
notif_data.spinner = nil
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user