Closed Shatur closed 3 years ago
Good suggestions, thanks!
Good suggestions, thanks!
Hm... This change triggers the following error:
Error detected while processing BufUnload Autocommands for "<buffer=52>":
E5108: Error executing lua ...vim/pack/plugins/opt/neogit/lua/neogit/popups/commit.lua:39: Vim(write):E382: Cannot write, 'buftype' option is set
Steps to reproduce
:NeogitStatus
cc
:w
:bdelete
@stevearc, if you will use :close
instead of :bdelete
, then your commit will contain comments.
Thanks for the report! The issue comes in here: https://github.com/TimUntersberger/neogit/blob/a859c0ddc526fafaa21e9613e11aa06ad9258e1c/lua/neogit/popups/commit.lua#L32-L40
Neogit is running g/^#/d
and :w!
on BufUnload. The way stickybuf works is by overriding the bufhidden option, so that changes when BufUnload will happen. What happens without stickybuf:
close
or bdelete
bufhidden
, which fires the BufUnload
autocmd before leaving the buffer/windowWith stickybuf before the change I just made:
close
My change does fix the issue with close
not removing the comments from the commit message. However, the error from bdelete
remains. I believe this is because bdelete
closes the window before deleting the buffer, and unlike the function inside stickybuf, it will not move the cursor back into the buffer before it deletes it. I don't have a good fix for this.
I don't want this plugin to provide any behavior by default that could cause errors under normal use, so I'm removing the pinning from the commit message. If you still want that behavior, add it back in your own config and use close
instead of bdelete
to avoid the error.
Thanks! I use the following workaround for buffer deletion: https://github.com/Shatur/neovim-config/blob/998f7e61c5ffc925ebe49f9b8a4280b4fc0346c0/lua/config_utils/buffers.lua#L15
I found that Neogit commit messsage could be marked as sticky too. It opened by Neogit vertically to NeogitStatus. This is how I use it:
I opened the issue because you may want to make it sticky by default.