mirror of
https://github.com/jdhao/nvim-config.git
synced 2025-06-08 14:14:33 +02:00
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
This commit is contained in:
parent
0830dfcf90
commit
d434627738
@ -145,3 +145,17 @@ function! utils#Get_titlestr() abort
|
|||||||
|
|
||||||
return l:title_str
|
return l:title_str
|
||||||
endfunction
|
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
|
||||||
|
|||||||
@ -89,4 +89,9 @@ function! s:quit_current_win() abort
|
|||||||
quit
|
quit
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
augroup git_repo_check
|
||||||
|
autocmd!
|
||||||
|
autocmd VimEnter,DirChanged * call utils#Inside_git_repo()
|
||||||
|
augroup END
|
||||||
"}
|
"}
|
||||||
|
|||||||
@ -178,15 +178,7 @@ require('packer').startup(
|
|||||||
-- use 'airblade/vim-gitgutter'
|
-- use 'airblade/vim-gitgutter'
|
||||||
|
|
||||||
-- Git command inside vim
|
-- Git command inside vim
|
||||||
use {'tpope/vim-fugitive', cond =
|
use {'tpope/vim-fugitive', event = 'User InGitRepo'}
|
||||||
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
|
-- Better git log display
|
||||||
use {'rbong/vim-flog', require = 'tpope/vim-fugitive', cmd = {'Flog'}}
|
use {'rbong/vim-flog', require = 'tpope/vim-fugitive', cmd = {'Flog'}}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user