-
Notifications
You must be signed in to change notification settings - Fork 24
/
init.lua
44 lines (41 loc) · 1.29 KB
/
init.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
---@class dropbar_source_t
---@field get_symbols fun(buf: integer, win: integer, cursor: integer[]): dropbar_symbol_t[]
local notified = false
---For backword compatibility
---@param get_symbols fun(buf: integer, win: integer, cursor: integer[]): dropbar_symbol_t[]
---@return dropbar_symbol_t[]
local function check_params(get_symbols, buf, win, cursor)
if
type(buf) ~= 'number'
or type(win) ~= 'number'
or type(cursor) ~= 'table'
then
if not notified then
vim.api.nvim_echo({
{ '[dropbar.nvim] ', 'Normal' },
{ 'get_symbols() now accepts three parameters: ', 'Normal' },
{ '{buf}, ', 'Normal' },
{ '{win}, ', 'WarningMsg' },
{ '{cursor} ', 'Normal' },
{ 'instead of two parameters: ', 'Normal' },
{ '{buf}, ', 'Normal' },
{ '{cursor}', 'Normal' },
{ '.\n', 'Normal' },
}, true, {})
notified = true
end
return {}
end
return get_symbols(buf, win, cursor)
end
---@type table<string, dropbar_source_t>
return setmetatable({}, {
__index = function(_, key)
local source = require('dropbar.sources.' .. key)
local _get_symbols = source.get_symbols
source.get_symbols = function(buf, win, cursor)
return check_params(_get_symbols, buf, win, cursor)
end
return source
end,
})