Skip to content

Commit

Permalink
feat(nvim): treat neogit buffers like sidebars
Browse files Browse the repository at this point in the history
  • Loading branch information
meatcar committed Oct 30, 2023
1 parent 99540a2 commit f97789c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
4 changes: 3 additions & 1 deletion home-manager/modules/neovim/nvim/lua/plugins/base.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ _G.me.o.sidebars = {
'trouble',
'neo-tree',
'fugitive',
'sagaoutline'
'sagaoutline',
'NeogitStatus',
'NeogitCommitMessage',
}

return {
Expand Down
19 changes: 18 additions & 1 deletion home-manager/modules/neovim/nvim/lua/plugins/git.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ return {
{ -- auto-complete Github issues in fugitive
'tpope/vim-rhubarb',
event = me.o.events.insert,
ft = 'gitcommit'
ft = { 'gitcommit', 'NeogitCommitMessage' }
},
{ -- Better merging (3-way becomes 2-way)
'samoshkin/vim-mergetool',
Expand Down Expand Up @@ -119,5 +119,22 @@ return {
diffview = true,
},
},
config = function(_, opts)
require('neogit').setup(opts)

local group = vim.api.nvim_create_augroup('neogit_me', { clear = true })
vim.api.nvim_create_autocmd("TabLeave", {
group = group,
pattern = "*",
desc = "Auto-close neogit when switching tabs",
callback = function(_)
for _, buf in ipairs(vim.fn.tabpagebuflist()) do
if vim.bo[buf].filetype == 'NeogitStatus' then
require('neogit').close()
end
end
end
})
end
},
}

0 comments on commit f97789c

Please sign in to comment.