Created
May 17, 2024 08:45
-
-
Save seandewar/bbbf6f276f980c091e22801c0db9656c to your computer and use it in GitHub Desktop.
Are deprecation messages in Neovim too annoying? Then enhance them with this little script!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local π·οΈ πͺ = vim.api.nvim_create_namespace('depreCATE') | |
vim.deprecate = function(name, alternative, version, plugin, backtrace) | |
local lines = { | |
"", | |
"π¨ π§π£ W A R N I N G ! ! ! ! π¨", | |
"", | |
"", | |
"π± " .. name .. " IS DEPRECATED!!!! π±", | |
"", | |
"IT WILL BE REMOVED IN " .. (plugin or "NVIM") .. " VERSION " .. version .. "!", | |
"", | |
} | |
if backtrace == nil or backtrace then | |
vim.list_extend(lines, vim.split(debug.traceback('', 2):sub(2), "\n")) | |
lines[#lines + 1] = "" | |
end | |
local w = vim.iter(lines):fold(0, function(acc, l) | |
return math.max(acc, #l) | |
end) | |
local h = #lines | |
vim.schedule(function() | |
local b = vim.api.nvim_create_buf(false, true) | |
vim.api.nvim_buf_set_lines(b, 0, -1, true, lines) | |
for i = 1, math.random(1, 1) do | |
local x = math.random(1, vim.o.columns - w - 3) | |
local y = math.random(1, vim.o.lines - h - vim.o.cmdheight - 3) | |
local πͺ = vim.api.nvim_open_win(b, true, { | |
relative = "editor", | |
row = y, | |
col = x, | |
width = w, | |
height = h, | |
border = "rounded", | |
zindex = 9001, | |
style = "minimal", | |
}) | |
vim.wo[πͺ].winfixbuf=true | |
vim.api.nvim_win_set_hl_ns(πͺ, π·οΈ πͺ) | |
vim.api.nvim_set_hl(π·οΈ πͺ, 'FloatBorder', {link = 'NormalFloat'}) | |
local β° = vim.uv.new_timer() | |
local π¨ = false | |
β°:start(0, 250, vim.schedule_wrap(function() | |
if not vim.api.nvim_win_is_valid(πͺ) then | |
return | |
end | |
π¨ = not π¨ | |
vim.api.nvim_set_hl(π·οΈ πͺ, 'NormalFloat', {bg = π¨ and '#ff0000' or '#ffff00', ctermbg = π¨ and 'red' or 'yellow', | |
fg = π¨ and '#ffffff' or '#000000', ctermfg = π¨ and 'white' or 'black'}) | |
vim.api.nvim__redraw({win = πͺ, valid = false}) | |
end)) | |
local β°2 = vim.uv.new_timer() | |
local vx = math.random(2) == 1 and 1 or -1 | |
local vy = math.random(2) == 1 and 1 or -1 | |
β°2:start(0, 50, vim.schedule_wrap(function() | |
if not vim.api.nvim_win_is_valid(πͺ) then | |
return | |
end | |
x = x + vx | |
if x <= 1 or x >= vim.o.columns - w - 2 then | |
vx = -vx | |
end | |
y = y + vy | |
if y <= 1 or y >= vim.o.lines - h - vim.o.cmdheight - 2 then | |
vy = -vy | |
end | |
vim.api.nvim_win_set_config(πͺ, {relative='editor',row = y, col = x}) | |
end)) | |
vim.api.nvim_create_autocmd('WinClosed', {pattern = tostring(πͺ), callback = function() | |
β°:stop() | |
β°:close() | |
β°2:stop() | |
β°2:close() | |
end}) | |
end | |
end) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment