neogit icon indicating copy to clipboard operation
neogit copied to clipboard

feat: add option to split popup window relative to the bottom of the editor

Open daephx opened this issue 2 years ago • 0 comments

Figured I'd open an issue before just making a PR.

The config.kind setting provides a few options: tab, replace, vsplit, and notably split which will open relative the the active window; there is the extra option to split_above which opens using the top modifier for the split command, making it open relative to the top of the editor window. But what about something like split_below which splits to the bottom of the editor?

A simple hack I have use is to set an autocmd with wincmd J on popup windows, as I have done this for similar buffers using fugitive, but for neogit? I believe this simple addition could not be out of place.

Looking at the code, this could be added by duplicating the following lines and changing the label to split_below and the vim command to bot split.

https://github.com/NeogitOrg/neogit/blob/00b4486197e7ad7cf98e128a3c663d79a2cc962f/lua/neogit/lib/buffer.lua#L220-L223

- elseif kind == "split_above" then 
+ elseif kind == "split_below" then 
-   vim.cmd("top split") 
+   vim.cmd("bot split") 
   api.nvim_set_current_buf(self.handle) 
   win = api.nvim_get_current_win() 

For those that make heavy use of quickfix or bottom splits for terminal buffers, this can cause some annoying window behaviour but this can still be a nice option for those that choose to make use of it! For me, id use it for NeogitPopup windows since the content can get cut off if you already have 3 or 4+ splits for the current tabpage.

daephx avatar Aug 24 '23 13:08 daephx