diff options
| author | jdhao <jdhao@hotmail.com> | 2021-08-07 02:32:12 +0800 |
|---|---|---|
| committer | jdhao <jdhao@hotmail.com> | 2021-08-07 02:32:12 +0800 |
| commit | d434627738c59473530d807cb645df6deb4c8e80 (patch) | |
| tree | c6866fdfa0906ef5b8bf5243af0f6865e76e603c /autoload | |
| parent | 0830dfcf90dc708330730808f2fd67f5b7f46ef3 (diff) | |
Fix: the loading condition for fugitive is wrong
We should load fugitive in the following two situations:
+ When we open nvim in a Git repository
+ When we are inside nvim and change the working directory to a Git
reposity
Diffstat (limited to 'autoload')
| -rw-r--r-- | autoload/utils.vim | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/autoload/utils.vim b/autoload/utils.vim index 9d84c9b..8ed401e 100644 --- a/autoload/utils.vim +++ b/autoload/utils.vim @@ -145,3 +145,17 @@ function! utils#Get_titlestr() abort return l:title_str endfunction + +" Check if we are inside a Git repo. +function! utils#Inside_git_repo() abort + let res = system('git rev-parse --is-inside-work-tree') + if match(res, 'true') == -1 + return v:false + else + " Manually trigger a speical user autocmd InGitRepo (to use it for + " lazyloading of fugitive by packer.nvim). + " See also https://github.com/wbthomason/packer.nvim/discussions/534. + doautocmd User InGitRepo + return v:true + endif +endfunction |
