Closed fnune closed 2 weeks ago
Yeah, I had a similar thought the other day. Is this something you want to take a crack at?
I can do it, but WDYT about the design alternatives?
I can make my own assumptions/decisions, but happy to hear what you think :)
You could probably get away with using a floating window that has the same background color as the buffer, that doesn't get focused on creation. Maybe even just vim.notify()
with some extra arguments?
Or, echo/redraw so it appears in the cmd line. The Refs buffer does that when loading cherries for a ref.
Statusbar could be fine, but I havent messed with that before.
I wouldn't put it as -part- of the status buffer though. That would get expensive to rerender just for a spinner
You could probably get away with using a floating window that has the same background color as the buffer
What do you mean by this? A sort of overlay on top of the Neogit status window?
Or something small on the side like a Noice notification? (but not using Noice, heh)
Statusbar could be fine, but I havent messed with that before.
Maybe this is an easy approach and a good start:
Example:
-- Neogit config
auto_show_console_error_only = true
-- Lualine example with lazy.nvim
return {
"nvim-lualine/lualine.nvim",
config = function()
local lualine = require("lualine")
lualine.setup({
sections = {
lualine_a = { "mode", require("neogit.process").status },
},
})
end,
}
Then it's mostly done.
You could probably get away with using a floating window that has the same background color as the buffer
What do you mean by this? A sort of overlay on top of the Neogit status window?
Yeah, like that. Noice (and fidget, nvim-notify, cmp, ...) just place a floating window. Without a border it would blend in very smoothly.
I think showing on error-only would make sense. Since I added some logic to check for git hooks a few days ago, the "timer" idea doesn't really make sense to me. Like, I suppose if something is taking a long time you might want to see why, but besides a hook I'm not sure what would take a long time.
Would the status line get repainted frequently enough to make a spinner meaningful? IIRC it's a poll model, not a push model, so if it stopped polling for updates you might get stale state shown. But maybe I'm wrong 🤷🏼 Regardless, I'm not against it.
Here's a little POC for a spinner in the message window, if you like:
api.nvim_create_user_command("SpinnerPOC", function(args)
local pattern = {
"-",
"\\",
"|",
"/"
}
local function setInterval(interval, callback)
local timer = vim.uv.new_timer()
timer:start(interval, interval, function()
callback()
end)
return timer
end
local function clearInterval(timer)
timer:stop()
timer:close()
end
local count = 0
local timer = setInterval(50, vim.schedule_wrap(function()
count = count + 1
vim.cmd(string.format("redraw | echomsg '%s Running Process'", pattern[(count % #pattern) + 1]))
end))
vim.defer_fn(
function()
clearInterval(timer)
vim.cmd("redraw | echomsg ''")
end,
3000
)
end, {
desc = "spin POC",
})
So I've been exploring using :h vim.notify
for this. It seems like the default Neovim implementation of vim.notify
does not allow one to update an existing notification. So if I make a vim.notify
call to update the spinner for each one of its frames, and then I happen to have a plugin like nvim-notify
installed, I get this:
That means that if I want to use vim.notify
I should probably choose between:
nvim-notify
), ormini-notify.nvim
, nvim-notify
...The reason I'm thinking about this is because I don't enjoy the idea of showing our own notification buffer, because I know users of notify replacement plugins would enjoy a notification in their own format.
I will explore the statusline idea for a bit now.
We used to have a bespoke notification component that I removed a while ago because it was from a time before the vim.notify()
interface, and the proliferation of those plugins. Thats just to say I'm not entirely keen on putting it back unless entirely needed and scoped more narrowly.
All sounds reasonable - just showing a popup without a nifty spinner doesn't really communicate what I think you have in mind here, and... we can already do that, so thats no fun.
Lemme know how the statusline idea goes :)
Basically something like this:
_G.neogit_progress_statusline_frame = "⠋"
local function on_neogit_process_start()
local spinners = { "⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏" }
local index = 1
local timer = vim.loop.new_timer()
timer:start(
0,
100,
vim.schedule_wrap(function()
_G.neogit_progress_statusline_frame = spinners[index] .. " Committing..."
index = (index % #spinners) + 1
vim.cmd("redrawstatus")
-- If lualine is installed: require("lualine").refresh()
end)
)
local function on_neogit_process_end()
_G.neogit_progress_statusline_frame = ""
vim.cmd("redrawstatus")
-- If lualine is installed: require("lualine").refresh()
timer:stop()
timer:close()
end
vim.defer_fn(on_neogit_process_end, 3000)
end
vim.api.nvim_create_user_command("NeogitProgressStart", on_neogit_process_start, { desc = "" })
function neogit_progress()
return _G.neogit_progress_statusline_frame or ""
end
Sample usage in Lualine:
Sample usage in a regular statusline:
vim.o.statusline = "%!v:lua.neogit_progress()"
I'm just exploring, please don't hesitate to say no to my ideas :smile:
Fixed in https://github.com/NeogitOrg/neogit/pull/1551 ! <3
I set my
console_timeout
to250
because many of the commands I run end up showing the console, so I'd rather see it quickly.However, most of the time I can just dismiss it. It will also close automatically. So that means it's not really of any use to me other than for the fact that it lets me know that something's happening and Neogit isn't frozen.
That's why I think this should be Neogit's behavior: