generated from 2KAbhishek/bare-minimum
-
-
Notifications
You must be signed in to change notification settings - Fork 11
/
notify.lua
56 lines (49 loc) · 1.39 KB
/
notify.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
local notify = require('notify')
local icons = require('lib.icons')
notify.setup({
background_colour = '#000',
fps = 30,
icons = {
DEBUG = icons.ui.Bug,
ERROR = icons.diagnostics.Error,
INFO = icons.diagnostics.Information,
TRACE = icons.ui.Bookmark,
WARN = icons.diagnostics.Warning,
},
level = 2,
render = 'default',
stages = 'fade_in_slide_out',
timeout = 2000,
top_down = true,
max_height = function()
return math.floor(vim.o.lines * 0.75)
end,
max_width = function()
return math.floor(vim.o.columns * 0.75)
end,
on_open = function(win)
vim.api.nvim_win_set_config(win, { zindex = 100 })
end,
})
-- Controls noisy notifications
local buffered_messages = {
'Client %d+ quit',
'No node found at cursor',
}
local message_notifications = {}
vim.notify = function(msg, level, opts)
opts = opts or {}
for _, pattern in ipairs(buffered_messages) do
if string.find(msg, pattern) then
if message_notifications[pattern] then
opts.replace = message_notifications[pattern]
end
opts.on_close = function()
message_notifications[pattern] = nil
end
message_notifications[pattern] = notify.notify(msg, level, opts)
return
end
end
notify.notify(msg, level, opts)
end