Skip to content

Commit f355801

Browse files
committed
The return of NEOGIT_SLAVE (I hope)
1 parent 5c55b73 commit f355801

File tree

1 file changed

+27
-10
lines changed

1 file changed

+27
-10
lines changed

init.lua

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -242,16 +242,6 @@ end
242242
local rtp = vim.opt.rtp
243243
rtp:prepend(lazypath)
244244

245-
-- [[ Configure and install plugins ]]
246-
--
247-
-- To check the current status of your plugins, run
248-
-- :Lazy
249-
--
250-
-- You can press `?` in this menu for help. Use `:q` to close the window
251-
--
252-
-- To update plugins you can run
253-
-- :Lazy update
254-
255245
PACKAGES = {
256246
'NMAC427/guess-indent.nvim', -- Detect tabstop and shiftwidth automatically
257247

@@ -283,6 +273,33 @@ PACKAGES = {
283273
vim.keymap.set('n', '<leader>gg', function()
284274
require('neogit').open { cwd = vim.fn.expand '%:p:h' }
285275
end, { desc = '[G]it [G]atus' })
276+
277+
-- Never interact with git except through Neogit!
278+
if os.getenv 'NEOGIT_SLAVE' then
279+
local registered_callback = nil
280+
vim.api.nvim_create_autocmd('User', {
281+
pattern = 'NeogitStatusRefreshed',
282+
callback = function()
283+
if registered_callback then
284+
return
285+
end
286+
registered_callback = true
287+
288+
vim.api.nvim_create_autocmd('BufEnter', {
289+
callback = function()
290+
for _, win in ipairs(vim.api.nvim_list_wins()) do
291+
local buf = vim.api.nvim_win_get_buf(win)
292+
local name = vim.api.nvim_buf_get_name(buf)
293+
if name:match 'Neogit' then
294+
return
295+
end
296+
end
297+
vim.cmd 'qa'
298+
end,
299+
})
300+
end,
301+
})
302+
end
286303
end,
287304
},
288305
-- Use `opts = {}` to automatically pass options to a plugin's `setup()` function, forcing the plugin to be loaded.

0 commit comments

Comments
 (0)