From 6f07d7e6cd23b7a76dc461fdfb1984717d233806 Mon Sep 17 00:00:00 2001 From: Tim Pope Date: Mon, 6 Sep 2021 19:01:04 -0400 Subject: [PATCH] Make initialization lazy --- plugin/fugitive.vim | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/plugin/fugitive.vim b/plugin/fugitive.vim index e5f0b98..bcd48d2 100644 --- a/plugin/fugitive.vim +++ b/plugin/fugitive.vim @@ -420,6 +420,9 @@ function! FugitiveDetect(...) abort if exists('b:git_dir') && b:git_dir =~# '^$\|' . s:bad_git_dir unlet b:git_dir endif + if a:0 > 1 && a:2 && !exists('#User#Fugitive') + return '' + endif if !exists('b:git_dir') let b:git_dir = FugitiveExtractGitDir(a:0 ? a:1 : bufnr('')) endif @@ -600,8 +603,9 @@ let g:io_fugitive = { augroup fugitive autocmd! - autocmd BufNewFile,BufReadPost * call FugitiveDetect(expand(':p')) - autocmd FileType netrw call FugitiveDetect(fnamemodify(get(b:, 'netrw_curdir', expand('')), ':p')) + autocmd BufNewFile,BufReadPost * + \ call FugitiveDetect(expand(':p'), 1) + autocmd FileType netrw call FugitiveDetect(fnamemodify(get(b:, 'netrw_curdir', expand(':p')), ':p'), 1) autocmd FileType git \ call fugitive#MapCfile()