1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-01-23 12:50:04 +08:00

feat(notify): share viml notifys

This commit is contained in:
Eric Wong 2024-03-31 00:08:50 +08:00
parent 32aec1ec5b
commit 18f2edc395
2 changed files with 12 additions and 2 deletions

View File

@ -29,6 +29,12 @@ scriptencoding utf-8
let s:notifications = {} let s:notifications = {}
function! SpaceVim#api#notify#shared_notifys() abort
return s:notifications
endfunction
" dictionary values and functions " dictionary values and functions
let s:self = {} let s:self = {}

View File

@ -68,7 +68,7 @@ function M.notify(msg, ...) -- {{{
vim.fn.setbufvar(M.border.bufnr, '&relativenumber', 0) vim.fn.setbufvar(M.border.bufnr, '&relativenumber', 0)
vim.fn.setbufvar(M.border.bufnr, '&cursorline', 0) vim.fn.setbufvar(M.border.bufnr, '&cursorline', 0)
vim.fn.setbufvar(M.border.bufnr, '&bufhidden', 'wipe') vim.fn.setbufvar(M.border.bufnr, '&bufhidden', 'wipe')
extend(notifications, { [M.hashkey] = M }) notifications[M.hashkey] = M
M.increase_window() M.increase_window()
if type(msg) == 'table' then if type(msg) == 'table' then
vim.fn.timer_start(M.timeout, M.close, { ['repeat'] = #msg }) vim.fn.timer_start(M.timeout, M.close, { ['repeat'] = #msg })
@ -137,7 +137,11 @@ function M.redraw_windows()
return return
end end
M.begin_row = 2 M.begin_row = 2
for _, hashkey in ipairs(notifications) do local viml_notify = vim.fn['SpaceVim#api#notify#shared_notifys']()
for hashkey, _ in pairs(viml_notify) do
M.begin_row = M.begin_row + msg_real_len(viml_notify[hashkey].message) + 2
end
for hashkey, _ in pairs(notifications) do
if hashkey ~= M.hashkey then if hashkey ~= M.hashkey then
M.begin_row = M.begin_row + msg_real_len(notifications[hashkey].message) + 2 M.begin_row = M.begin_row + msg_real_len(notifications[hashkey].message) + 2
else else