shadmansaleh f68d81d351 [Deprection] Enhance: Provide an uniform interface for color options
- Now all color related options and themes color definition have same
  semantics. They can either be a table containing values like bg,fg,gui
  or a string. When it's a string it's treated as a highlight group name
  and newly created group is linked to that group.
- Using string values to define foreground colors in options like
  color_error/color_added in diagnostics and diff component has been
  deprecated.
- Added a decent way of notifying affected users of deprecations and
  breaking changes.
2021-08-09 14:03:12 +06:00

45 lines
1.1 KiB
Lua

-- To provide notices for user
local M = {}
local notices = {}
function M.add_notice(notice)
if type(notice) == 'string' then notice = vim.split(notice, "\n") end
table.insert(notices, notice)
end
function M.notice_message_startup()
if #notices > 0 then
vim.cmd('command! -nargs=0 LualineNotices lua require"lualine.utils.notices".show_notices()')
vim.schedule(function()
vim.notify(
"lualine: There are some issues with your config. Run :LualineNotices for details",
vim.log.levels.WARN, {})
end)
end
end
function M.show_notices()
vim.cmd [[
:silent! new
:silent! setl ft=markdown bt=nofile nobuflisted bh=wipe
:silent! nnoremap <silent><buffer> q <cmd>bd<cr>
:silent! normal ggdG
]]
local ok, _ = pcall(vim.api.nvim_buf_set_name, 0, "Lualine Notices")
if not ok then
vim.notify("Lualine Notices is already open in another window",
vim.log.levels.ERROR, {})
vim.cmd('normal q')
return
end
local notice = vim.tbl_flatten(notices)
vim.fn.append(0, notice)
vim.api.nvim_win_set_cursor(0, {1, 0})
end
function M.clear_notices()
notices = {}
end
return M