mirror of
https://git.aramjonghu.nl/AramJonghu/nvim.git
synced 2026-06-07 00:48:24 +02:00
stylua and removal mason reliance
This commit is contained in:
+51
-59
@@ -1,7 +1,7 @@
|
||||
vim.notify = require('notify')
|
||||
local dap = require('dap')
|
||||
vim.notify = require "notify"
|
||||
local dap = require "dap"
|
||||
|
||||
require('notify').setup({
|
||||
require("notify").setup {
|
||||
render = "wrapped-default",
|
||||
timeout = 6000,
|
||||
max_width = 50,
|
||||
@@ -13,20 +13,22 @@ require('notify').setup({
|
||||
WARN = "",
|
||||
INFO = "",
|
||||
DEBUG = "",
|
||||
TRACE = "✎"
|
||||
TRACE = "✎",
|
||||
},
|
||||
on_open = function(win)
|
||||
-- vim.api.nvim_win_set_option(win, 'wrap', true)
|
||||
vim.api.nvim_win_set_option(win, 'breakat', ' ')
|
||||
end
|
||||
})
|
||||
vim.api.nvim_win_set_option(win, "breakat", " ")
|
||||
end,
|
||||
}
|
||||
|
||||
-- Utility functions shared between progress reports for LSP and DAP
|
||||
|
||||
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] = {}
|
||||
@@ -35,7 +37,7 @@ 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)
|
||||
@@ -47,10 +49,12 @@ local function update_spinner(client_id, token)
|
||||
notif_data.notification = vim.notify(nil, nil, {
|
||||
hide_from_history = true,
|
||||
icon = spinner_frames[new_spinner],
|
||||
replace = notif_data.notification
|
||||
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
|
||||
|
||||
@@ -70,7 +74,9 @@ 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)
|
||||
|
||||
@@ -78,29 +84,24 @@ 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
|
||||
hide_from_history = false,
|
||||
})
|
||||
|
||||
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", {
|
||||
notif_data.notification = vim.notify(val.message and format_message(val.message) or "Complete", "info", {
|
||||
icon = "",
|
||||
replace = notif_data.notification,
|
||||
timeout = 6000
|
||||
timeout = 6000,
|
||||
})
|
||||
|
||||
notif_data.spinner = nil
|
||||
@@ -108,52 +109,43 @@ vim.lsp.handlers["$/progress"] = function(_, result, ctx)
|
||||
end
|
||||
|
||||
-- table from lsp severity to vim severity.
|
||||
local severity = {"error", "warn", "info"}
|
||||
local severity = { "error", "warn", "info" }
|
||||
|
||||
vim.lsp.handlers["window/showMessage"] =
|
||||
function(err, method, params, client_id)
|
||||
vim.notify(method.message, severity[params.type])
|
||||
end
|
||||
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)
|
||||
local notif_data = get_notif_data("dap", body.progressId)
|
||||
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)
|
||||
notif_data.notification = vim.notify(message, "info", {
|
||||
title = format_title(body.title, session.config.type),
|
||||
icon = spinner_frames[1],
|
||||
timeout = false,
|
||||
hide_from_history = false
|
||||
})
|
||||
local message = format_message(body.message, body.percentage)
|
||||
notif_data.notification = vim.notify(message, "info", {
|
||||
title = format_title(body.title, session.config.type),
|
||||
icon = spinner_frames[1],
|
||||
timeout = false,
|
||||
hide_from_history = false,
|
||||
})
|
||||
|
||||
notif_data.notification.spinner = 1, update_spinner("dap",
|
||||
body.progressId)
|
||||
end
|
||||
notif_data.notification.spinner = 1, update_spinner("dap", body.progressId)
|
||||
end
|
||||
|
||||
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
|
||||
})
|
||||
end
|
||||
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,
|
||||
})
|
||||
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", {
|
||||
notif_data.notification = vim.notify(body.message and format_message(body.message) or "Complete", "info", {
|
||||
icon = "",
|
||||
replace = notif_data.notification,
|
||||
timeout = 6000
|
||||
timeout = 6000,
|
||||
})
|
||||
notif_data.spinner = nil
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user