2021-10-22 23:46:43 +02:00
|
|
|
local M = {}
|
|
|
|
|
2022-01-02 10:25:20 +01:00
|
|
|
local Log = require "lvim.core.log"
|
|
|
|
|
|
|
|
local defaults = {
|
2022-10-06 03:35:14 +02:00
|
|
|
active = true,
|
2022-01-02 10:25:20 +01:00
|
|
|
on_config_done = nil,
|
|
|
|
opts = {
|
|
|
|
---@usage Animation style one of { "fade", "slide", "fade_in_slide_out", "static" }
|
|
|
|
stages = "slide",
|
|
|
|
|
|
|
|
---@usage Function called when a new window is opened, use for changing win settings/config
|
|
|
|
on_open = nil,
|
|
|
|
|
|
|
|
---@usage Function called when a window is closed
|
|
|
|
on_close = nil,
|
|
|
|
|
|
|
|
---@usage timeout for notifications in ms, default 5000
|
|
|
|
timeout = 5000,
|
|
|
|
|
|
|
|
-- Render function for notifications. See notify-render()
|
|
|
|
render = "default",
|
|
|
|
|
|
|
|
---@usage highlight behind the window for stages that change opacity
|
|
|
|
background_colour = "Normal",
|
|
|
|
|
|
|
|
---@usage minimum width for notification windows
|
|
|
|
minimum_width = 50,
|
|
|
|
|
|
|
|
---@usage Icons for the different levels
|
|
|
|
icons = {
|
2022-10-03 05:48:23 +02:00
|
|
|
ERROR = lvim.icons.diagnostics.Error,
|
|
|
|
WARN = lvim.icons.diagnostics.Warning,
|
|
|
|
INFO = lvim.icons.diagnostics.Information,
|
|
|
|
DEBUG = lvim.icons.diagnostics.Debug,
|
|
|
|
TRACE = lvim.icons.diagnostics.Trace,
|
2021-10-22 23:46:43 +02:00
|
|
|
},
|
2022-01-02 10:25:20 +01:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
function M.config()
|
2022-04-28 16:30:39 +02:00
|
|
|
if not lvim.use_icons then
|
|
|
|
defaults.opts.icons = {
|
|
|
|
ERROR = "[ERROR]",
|
|
|
|
WARN = "[WARNING]",
|
2022-10-03 03:19:59 +02:00
|
|
|
INFO = "[INFO]",
|
2022-04-28 16:30:39 +02:00
|
|
|
DEBUG = "[DEBUG]",
|
|
|
|
TRACE = "[TRACE]",
|
|
|
|
}
|
|
|
|
end
|
2022-01-02 10:25:20 +01:00
|
|
|
lvim.builtin.notify = vim.tbl_deep_extend("force", defaults, lvim.builtin.notify or {})
|
2021-10-22 23:46:43 +02:00
|
|
|
end
|
|
|
|
|
2022-01-02 10:25:20 +01:00
|
|
|
function M.setup()
|
|
|
|
if #vim.api.nvim_list_uis() == 0 then
|
|
|
|
-- no need to configure notifications in headless
|
|
|
|
return
|
2021-10-23 13:11:05 +02:00
|
|
|
end
|
|
|
|
|
2022-01-02 10:25:20 +01:00
|
|
|
local opts = lvim.builtin.notify and lvim.builtin.notify.opts or defaults
|
|
|
|
local notify = require "notify"
|
|
|
|
|
|
|
|
notify.setup(opts)
|
|
|
|
vim.notify = notify
|
|
|
|
Log:configure_notifications(notify)
|
2021-10-23 13:11:05 +02:00
|
|
|
end
|
|
|
|
|
2021-10-22 23:46:43 +02:00
|
|
|
return M
|