diff options
Diffstat (limited to 'lua/lvim/core/notify.lua')
-rw-r--r-- | lua/lvim/core/notify.lua | 84 |
1 files changed, 49 insertions, 35 deletions
diff --git a/lua/lvim/core/notify.lua b/lua/lvim/core/notify.lua index 5339357b..cb62778f 100644 --- a/lua/lvim/core/notify.lua +++ b/lua/lvim/core/notify.lua @@ -1,45 +1,59 @@ local M = {} -function M.config() - local pallete = require "onedarker.palette" - - lvim.builtin.notify = { - active = false, - on_config_done = nil, - -- TODO: update after https://github.com/rcarriga/nvim-notify/pull/24 - opts = { - ---@usage Animation style one of { "fade", "slide", "fade_in_slide_out", "static" } - stages = "slide", - - ---@usage timeout for notifications in ms, default 5000 - timeout = 5000, - - ---@usage highlight behind the window for stages that change opacity - background_colour = pallete.fg, - - ---@usage Icons for the different levels - icons = { - ERROR = "ï™™", - WARN = "", - INFO = "ï µ", - DEBUG = "", - TRACE = "✎", - }, +local Log = require "lvim.core.log" + +local defaults = { + active = false, + 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 = { + ERROR = "ï™™", + WARN = "", + INFO = "ï µ", + DEBUG = "", + TRACE = "✎", }, - } + }, +} + +function M.config() + lvim.builtin.notify = vim.tbl_deep_extend("force", defaults, lvim.builtin.notify or {}) end -M.params_injecter = function(_, entry) - -- FIXME: this is currently getting ignored or is not passed correctly - for key, value in pairs(lvim.builtin.notify.opts) do - entry[key] = value +function M.setup() + if #vim.api.nvim_list_uis() == 0 then + -- no need to configure notifications in headless + return end - return entry -end -M.default_namer = function(logger, entry) - entry["title"] = logger.name - return entry + 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) end return M |