Closed seblj closed 1 year ago
I think this isn't a problem with the mapping I just checked and the mapping is exactly the same as it was before opening the buffer
perhaps some autocommands get deleted if you leave and reenter the buffer or sth like that
This is indeed not a problem with lazy. I assume startify simply doesnt exit Neovim when another buffer or window has been created in the meantime
This is indeed not a problem with lazy. I assume startify simply doesnt exit Neovim when another buffer or window has been created in the meantime
The startify mapping works perfectly fine if I use :q<CR>
, :close<CR>
or anything like that on the lazy
buffer, so I think it's a bit fast to say that it's definitely not a problem with lazy and the close() function that it is mapped to.
As I said, startify checks if any other buffers are present: https://github.com/mhinz/vim-startify/blob/81e36c352a8deea54df5ec1e2f4348685569bed2/autoload/startify.vim#L1008
When you close the Lazy window, a new buffer (3) gets created, by something. I can assure you it's not Lazy that's doing that.
Because there's then 2 buffers left, startify wont close Neovim. as I mentioned before
As I said, startify checks if any other buffers are present: https://github.com/mhinz/vim-startify/blob/81e36c352a8deea54df5ec1e2f4348685569bed2/autoload/startify.vim#L1008
When you close the Lazy window, a new buffer (3) gets created, by something. I can assure you it's not Lazy that's doing that.
Because there's then 2 buffers left, startify wont close Neovim. as I mentioned before
I tried to look into this a bit more, and I think I found the issue. I don't know why it happens, but I assume it has something to do with vim.api.nvim_win_close()
. It states in the docs that The buffer will become hidden, even if 'hidden' is not set.
.
If I change the order of the functions to close the window, and then delete the buffer if it is valid, the issue not there anymore. I think there is something weird happening if the buffer is deleted before the window is closed.
diff --git a/lua/lazy/view/init.lua b/lua/lazy/view/init.lua
index b2fcbb9..e82f644 100644
--- a/lua/lazy/view/init.lua
+++ b/lua/lazy/view/init.lua
@@ -102,12 +102,12 @@ function M.show(mode)
M._buf = nil
vim.diagnostic.reset(Config.ns, buf)
vim.schedule(function()
- if vim.api.nvim_buf_is_valid(buf) then
- vim.api.nvim_buf_delete(buf, { force = true })
- end
if vim.api.nvim_win_is_valid(win) then
vim.api.nvim_win_close(win, true)
end
+ if vim.api.nvim_buf_is_valid(buf) then
+ vim.api.nvim_buf_delete(buf, { force = true })
+ end
end)
end
Would you be willing to accept a PR with that change @folke ?
Describe the bug If I have startify installed and use the keymap
q
mapped bylazy.nvim
to quit the popup window. If I then pressq
that startify has mapped to quit, it can't quit because of the buffer fromlazy.nvim
Which version of Neovim are you using? v0.9.0-dev-521+g1c4794944
To Reproduce Make sure to read https://github.com/folke/lazy.nvim/wiki/Minimal-%60init.lua%60-to-Reproduce-an-Issue
Steps to reproduce the behavior:
nvim -u repro.lua
Lazy
q
q
Expected Behavior I expect it to quit neovim when pressing
q
in startify buffer.Screenshots
https://user-images.githubusercontent.com/5160701/208999455-8c59175e-78ce-41bc-904d-c35334bf724a.mov
You can see from the screenshot that the second time I open neovim and not open a lazy popup window, it is possible to close with
q
like normal. But when I open a lazy popup window, it is not possiblerepro.lua
```lua local root = vim.fn.fnamemodify("./.repro", ":p") -- set stdpaths to use .repro for _, name in ipairs({ "config", "data", "state", "cache" }) do vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name end -- bootstrap lazy local lazypath = root .. "/plugins/lazy.nvim" if not vim.loop.fs_stat(lazypath) then vim.fn.system({ "git", "clone", "--filter=blob:none", "--single-branch", "https://github.com/folke/lazy.nvim.git", lazypath, }) end vim.opt.runtimepath:prepend(lazypath) -- install plugins local plugins = { -- do not remove the colorscheme! "folke/tokyonight.nvim", "mhinz/vim-startify", -- add any other pugins here } require("lazy").setup(plugins, { root = root .. "/plugins", }) -- add anything else here vim.opt.termguicolors = true -- do not remove the colorscheme! vim.cmd([[colorscheme tokyonight]]) ```Log Please include any related errors from the Noice log file. (open with
:Lazy log
)Lazy log