-
Notifications
You must be signed in to change notification settings - Fork 236
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow showing a loading spinner instead of showing the console unless there is an error #1519
Comments
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 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 |
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. |
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 That means that if I want to use
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 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 a regular statusline: vim.o.statusline = "%!v:lua.neogit_progress()" |
I'm just exploring, please don't hesitate to say no to my ideas 😄 |
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:
The text was updated successfully, but these errors were encountered: