From 3f0c6650f2ac5746dafdc866261e6cd8aa3cef52 Mon Sep 17 00:00:00 2001 From: jdhao Date: Thu, 29 Jul 2021 23:11:30 +0800 Subject: [PATCH] Update load condition for vim-fugitive See https://stackoverflow.com/a/38088814/6064933 for how to check if we are inside a Git repository. --- lua/plugins.lua | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lua/plugins.lua b/lua/plugins.lua index 1f86932..4f9a58a 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -178,7 +178,15 @@ require('packer').startup( -- use 'airblade/vim-gitgutter' -- Git command inside vim - use {'tpope/vim-fugitive', cmd = {'Git', 'Gwrite'}} + use {'tpope/vim-fugitive', cond = + function() + local res = vim.fn.system('git rev-parse --is-inside-work-tree') + if string.find(res, 'true') then + return true + else + return false + end + end} -- Better git log display use {'rbong/vim-flog', require = 'tpope/vim-fugitive', cmd = {'Flog'}}