|
242 | 242 | local rtp = vim.opt.rtp |
243 | 243 | rtp:prepend(lazypath) |
244 | 244 |
|
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 | | - |
255 | 245 | PACKAGES = { |
256 | 246 | 'NMAC427/guess-indent.nvim', -- Detect tabstop and shiftwidth automatically |
257 | 247 |
|
@@ -283,6 +273,33 @@ PACKAGES = { |
283 | 273 | vim.keymap.set('n', '<leader>gg', function() |
284 | 274 | require('neogit').open { cwd = vim.fn.expand '%:p:h' } |
285 | 275 | 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 |
286 | 303 | end, |
287 | 304 | }, |
288 | 305 | -- Use `opts = {}` to automatically pass options to a plugin's `setup()` function, forcing the plugin to be loaded. |
|
0 commit comments