fidget.nvim
fidget.nvim copied to clipboard
Close the floating window manually
When saving a session using a session management plugin, or even vim builtin mksession
, if some floating windows are open, they will be recorded into the session file but as normal windows instead of floating windows. So in the future when we want to load the session, the window position and layout will be wrong.
My workaround is that before saving a session, close all the floating windows using the script below.
function M.close_all_floating_wins()
for _, win in ipairs(vim.api.nvim_list_wins()) do
local config = vim.api.nvim_win_get_config(win)
if config.relative ~= "" then
vim.api.nvim_win_close(win, false)
-- print('Closing window', win)
end
end
end
However, the fidget floating windows cannot be closed. So I am wondering whether it is possible to add a command to close fidget manually? Or how can we check if fidget is running or not?
Thank you very much.
Have you tried :FidgetClose
? https://github.com/j-hui/fidget.nvim/blob/main/doc/fidget.md#fidgetclose
Yes I tried but I still cannot close its floating windows. I will try it again right now.
Hi @j-hui I tried it again already just now and the floating windows showing the progress couldn't be closed.
https://user-images.githubusercontent.com/11582667/166089986-70875504-e061-442e-bbb6-955b1da81fe2.mov
I ran : FidgetClose
3 times in a row however, the floating windows were still there.
Thank you.
I also encountered this problem, I was in the auto-session
hook to do these operations
The result is alleviated, but it still happens in very occasional cases
local opts = {
log_level = 'info',
auto_session_enable_last_session = false,
auto_session_enabled = true,
auto_save_enabled = nil,
auto_restore_enabled = nil,
auto_session_suppress_dirs = nil,
pre_save_cmds = {
"lua require'nvim-tree.view'.close()",
"lua require'symbols-outline.preview'.close()",
'FidgetClose()', -- this line
},
}
require('auto-session').setup(opts)
Hi @j-hui any updates on this? Thank you.
@rockyzhang24 sorry I haven't had a chance to look into this yet
@j-hui Okay no rush, I was just asking. Thank you.
The session save and restore issue if there are floating windows was fixed via this commit (https://github.com/neovim/neovim/commit/3fe6bf3a1e50299dbdd6314afbb18e468eb7ce08). So now, fidget
won't bring about issues when we store the session with fidget
progress floating windows open and restore later.
I believe an explicit command to close the floating windows manually is still useful. But no rush at all. :)
Thank you very much.
As of #143, you can now do this programmatically via fidget.notification.window.close()
(technically an internal API, but let me know if it becomes an important part of your workflow, and I'll commit to stabilizing it).
Closing this issue for now, but let me know if there's any window management APIs you'd like exposed.