-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
notify.lua
90 lines (81 loc) · 2.28 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
return {
'rcarriga/nvim-notify',
keymaps = { { 'n', '<space>N', ':Telescope notify<CR>', { silent = true } } },
config = function(config)
local notify = require('notify')
notify.setup(config.notify)
vim.notify = notify
end,
defaultConfig = function(config)
local symbolMap = config.symbolMap
return {
'notify',
{
background_colour = config.colors.black,
fps = 30,
icons = {
ERROR = symbolMap.ERROR,
WARN = symbolMap.WARN,
INFO = symbolMap.INFO,
DEBUG = symbolMap.DEBUG,
TRACE = symbolMap.TRACE,
},
level = vim.log.levels.INFO, -- Minimum log level to display. See :h vim.log.levels
max_width = 100, -- Max number of columns for popup messages
minimum_width = 40, -- Minimum number of columns for popup message
max_height = 20,
render = 'default',
stages = 'fade_in_slide_out',
timeout = 2000, -- Default timeout for notification
top_down = true,
on_open = function(win)
-- Always wrap text in Notify popup window
vim.api.nvim_win_set_option(win, 'wrap', true)
end,
},
}
end,
commands = {
Notify = {
function(opts)
local args = opts.fargs
vim.notify(args[1], args[2] or 'info')
end,
{
nargs = '+',
desc = 'Send message to notification window. Usage: :Notify <message> [info|warn|error]',
},
},
NotifyClean = {
function()
vim.notify.dismiss({ pending = true, silent = true })
end,
{ desc = 'Dismiss all notification windows currently displayed' },
},
},
highlights = function(config)
local c = config.colors
return {
NotifyERRORBorder = { fg = c.red },
NotifyERRORIcon = { fg = c.red },
NotifyERRORTitle = { fg = c.red },
NotifyWARNBorder = { fg = c.yellow },
NotifyWARNIcon = { fg = c.yellow },
NotifyWARNTitle = { fg = c.yellow },
NotifyINFOBorder = { fg = c.blue },
NotifyINFOIcon = { fg = c.blue },
NotifyINFOTitle = { fg = c.blue },
NotifyDEBUGBorder = { fg = c.purple },
NotifyDEBUGIcon = { fg = c.purple },
NotifyDEBUGTitle = { fg = c.purple },
NotifyTRACEBorder = { fg = c.orange },
NotifyTRACEIcon = { fg = c.orange },
NotifyTRACETitle = { fg = c.orange },
}
end,
filetypes = {
notify = function(args)
vim.api.nvim_buf_set_keymap(args.buf, 'n', 'q', ':q<CR>', { silent = true })
end,
},
}