[mini.notify] Support for both fidget-like and regular notification windows #1602
abeldekat
started this conversation in
Show and tell
Replies: 2 comments 17 replies
-
|
Thanks for sharing! Very nice idea! The implementation itself looks a bit fragile as it depends on how 'mini.notify' creates/stores/updates buffers, which is subject to change without prior notice. My first attempt at this would have been writing own LSP handler for "$/progress", similarly to how 'mini.notify' does it (here is how it sets it, but not sure it needs to be this robust for personal config). |
Beta Was this translation helpful? Give feedback.
15 replies
-
|
@abeldekat Another possible solution I could manage notify.mp4local win_config = function()
local has_statusline = vim.o.laststatus > 0
local pad = vim.o.cmdheight + (has_statusline and 1 or 0)
local notify_lps = {
anchor = "SE",
title = "",
footer = {
{
(vim.b.icon or "") .. (" %s"):format((vim.b.tool or "")),
"WarningMsg",
},
},
footer_pos = "right",
border = "solid",
col = vim.o.columns,
row = vim.o.lines - pad,
}
--stylua: ignore
return notify_lps
end
local content = {
format = function(str)
if vim.b.not_lsp_progress then
return str.msg
end
local parts = vim.split(str.msg, ": ")
local action = parts[2] and parts[2] or ""
local tool = parts[1] or ""
-- stylua: ignore
local progress_match = action:match("(%d+/[%d]+)") or ""
local percent_match = action:match("(%d+%%)") or ""
-- stylua: ignore
action = action:gsub("%s*%d+/%d+", ""):gsub("%s*%(%d+%%%)", ""):gsub("%s*%([^)]+%)", ""):gsub("%s+$", "")
action = table.concat(vim.list_slice(vim.split(action, " "), 1, 2), " ")
vim.b.tool = tool
str.hl_group = "Comment"
-- stylua: ignore
return string.format(
"%-5s %-4s %s",
progress_match, percent_match, action
)
end,
}
MiniNotify.setup({
winblend = 0,
window = { config = win_config },
content = content,
lsp_progress = {
enable = true,
duration_last = 1000,
},
})
vim.notify = MiniNotify.make_notify()
local notify = vim.notify
vim.notify = function(msg, level, opts)
opts = opts or {}
vim.b.tool = opts.title
vim.b.not_lsp_progress = true
vim.b.icon = opts.icon or ""
vim.b.mininotify_config = {
window = {
config = function()
local notify_lsp = {
anchor = "NE",
title = {
{
((vim.b.tool or "") or ""),
"WarningMsg",
},
},
title_pos = "center",
}
return notify_lsp
end,
},
}
notify(msg, level, opts)
vim.defer_fn(function()
vim.b.mininotify_config = {
window = {
config = win_config,
},
}
vim.b.not_lsp_progress = false
end, 500)
end(@echasnovski Opinions?) |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
mini_notify.mp4
I wanted to replace fidget.nvim with mini.notify. I already used mini.notify for regular messages.
Using two different window configs and some autocommands, mini.notify is now also displaying lsp_progress feedback in almost the same way as fidget.nvim.
Final version: See this comment
First attempt
The code:
Beta Was this translation helpful? Give feedback.
All reactions