mirror of
https://github.com/tpope/vim-fugitive.git
synced 2025-11-14 06:13:51 -05:00
Gather up global autocommands and functions
This commit is contained in:
@@ -261,14 +261,48 @@ function! FugitiveDetect(path) abort
|
|||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! FugitiveStatusline(...) abort
|
||||||
|
if !exists('b:git_dir')
|
||||||
|
return ''
|
||||||
|
endif
|
||||||
|
return fugitive#Statusline()
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! FugitiveHead(...) abort
|
||||||
|
if !exists('b:git_dir')
|
||||||
|
return ''
|
||||||
|
endif
|
||||||
|
return fugitive#repo().head(a:0 ? a:1 : 0)
|
||||||
|
endfunction
|
||||||
|
|
||||||
augroup fugitive
|
augroup fugitive
|
||||||
autocmd!
|
autocmd!
|
||||||
|
|
||||||
autocmd BufNewFile,BufReadPost * call FugitiveDetect(expand('%:p'))
|
autocmd BufNewFile,BufReadPost * call FugitiveDetect(expand('%:p'))
|
||||||
autocmd FileType netrw call FugitiveDetect(fnamemodify(get(b:, 'netrw_curdir', @%), ':p'))
|
autocmd FileType netrw call FugitiveDetect(fnamemodify(get(b:, 'netrw_curdir', @%), ':p'))
|
||||||
autocmd User NERDTreeInit,NERDTreeNewRoot call FugitiveDetect(b:NERDTree.root.path.str())
|
autocmd User NERDTreeInit,NERDTreeNewRoot call FugitiveDetect(b:NERDTree.root.path.str())
|
||||||
autocmd VimEnter * if expand('<amatch>')==''|call FugitiveDetect(getcwd())|endif
|
autocmd VimEnter * if expand('<amatch>')==''|call FugitiveDetect(getcwd())|endif
|
||||||
autocmd CmdWinEnter * call FugitiveDetect(expand('#:p'))
|
autocmd CmdWinEnter * call FugitiveDetect(expand('#:p'))
|
||||||
autocmd BufWinLeave * execute getwinvar(+bufwinnr(+expand('<abuf>')), 'fugitive_leave')
|
|
||||||
|
autocmd BufReadCmd index{,.lock}
|
||||||
|
\ if FugitiveIsGitDir(expand('<amatch>:p:h')) |
|
||||||
|
\ exe fugitive#BufReadStatus() |
|
||||||
|
\ elseif filereadable(expand('<amatch>')) |
|
||||||
|
\ read <amatch> |
|
||||||
|
\ 1delete |
|
||||||
|
\ endif
|
||||||
|
autocmd FileReadCmd fugitive://**//[0-3]/** exe fugitive#FileRead()
|
||||||
|
autocmd BufReadCmd fugitive://**//[0-3]/** exe fugitive#BufReadIndex()
|
||||||
|
autocmd BufWriteCmd fugitive://**//[0-3]/** exe fugitive#BufWriteIndex()
|
||||||
|
autocmd BufReadCmd fugitive://**//[0-9a-f][0-9a-f]* exe fugitive#BufReadObject()
|
||||||
|
autocmd FileReadCmd fugitive://**//[0-9a-f][0-9a-f]* exe fugitive#FileRead()
|
||||||
|
|
||||||
|
autocmd User Flags call Hoist('buffer', function('FugitiveStatusline'))
|
||||||
|
|
||||||
|
autocmd User Fugitive
|
||||||
|
\ if &filetype =~# '^git\%(commit\)\=$' && &foldtext ==# 'foldtext()' |
|
||||||
|
\ set foldtext=fugitive#Foldtext() |
|
||||||
|
\ endif
|
||||||
augroup END
|
augroup END
|
||||||
|
|
||||||
" Section: Initialization
|
" Section: Initialization
|
||||||
@@ -2030,6 +2064,7 @@ augroup fugitive_blame
|
|||||||
autocmd Syntax fugitiveblame call s:BlameSyntax()
|
autocmd Syntax fugitiveblame call s:BlameSyntax()
|
||||||
autocmd User Fugitive if s:buffer().type('file', 'blob') | exe "command! -buffer -bar -bang -range=0 -nargs=* Gblame :execute s:Blame(<bang>0,<line1>,<line2>,<count>,[<f-args>])" | endif
|
autocmd User Fugitive if s:buffer().type('file', 'blob') | exe "command! -buffer -bar -bang -range=0 -nargs=* Gblame :execute s:Blame(<bang>0,<line1>,<line2>,<count>,[<f-args>])" | endif
|
||||||
autocmd ColorScheme,GUIEnter * call s:RehighlightBlame()
|
autocmd ColorScheme,GUIEnter * call s:RehighlightBlame()
|
||||||
|
autocmd BufWinLeave * execute getwinvar(+bufwinnr(+expand('<abuf>')), 'fugitive_leave')
|
||||||
augroup END
|
augroup END
|
||||||
|
|
||||||
function! s:linechars(pattern) abort
|
function! s:linechars(pattern) abort
|
||||||
@@ -2826,18 +2861,6 @@ endfunction
|
|||||||
|
|
||||||
augroup fugitive_files
|
augroup fugitive_files
|
||||||
autocmd!
|
autocmd!
|
||||||
autocmd BufReadCmd index{,.lock}
|
|
||||||
\ if FugitiveIsGitDir(expand('<amatch>:p:h')) |
|
|
||||||
\ exe fugitive#BufReadStatus() |
|
|
||||||
\ elseif filereadable(expand('<amatch>')) |
|
|
||||||
\ read <amatch> |
|
|
||||||
\ 1delete |
|
|
||||||
\ endif
|
|
||||||
autocmd FileReadCmd fugitive://**//[0-3]/** exe fugitive#FileRead()
|
|
||||||
autocmd BufReadCmd fugitive://**//[0-3]/** exe fugitive#BufReadIndex()
|
|
||||||
autocmd BufWriteCmd fugitive://**//[0-3]/** exe fugitive#BufWriteIndex()
|
|
||||||
autocmd BufReadCmd fugitive://**//[0-9a-f][0-9a-f]* exe fugitive#BufReadObject()
|
|
||||||
autocmd FileReadCmd fugitive://**//[0-9a-f][0-9a-f]* exe fugitive#FileRead()
|
|
||||||
autocmd FileType git
|
autocmd FileType git
|
||||||
\ if exists('b:git_dir') |
|
\ if exists('b:git_dir') |
|
||||||
\ call s:JumpInit() |
|
\ call s:JumpInit() |
|
||||||
@@ -3143,22 +3166,6 @@ function! fugitive#statusline(...) abort
|
|||||||
return fugitive#Statusline()
|
return fugitive#Statusline()
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! FugitiveStatusline(...) abort
|
|
||||||
if !exists('b:git_dir')
|
|
||||||
return ''
|
|
||||||
endif
|
|
||||||
|
|
||||||
return fugitive#Statusline()
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! FugitiveHead(...) abort
|
|
||||||
if !exists('b:git_dir')
|
|
||||||
return ''
|
|
||||||
endif
|
|
||||||
|
|
||||||
return fugitive#repo().head(a:0 ? a:1 : 0)
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! fugitive#head(...) abort
|
function! fugitive#head(...) abort
|
||||||
if !exists('b:git_dir')
|
if !exists('b:git_dir')
|
||||||
return ''
|
return ''
|
||||||
@@ -3167,11 +3174,6 @@ function! fugitive#head(...) abort
|
|||||||
return s:repo().head(a:0 ? a:1 : 0)
|
return s:repo().head(a:0 ? a:1 : 0)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
augroup fugitive_statusline
|
|
||||||
autocmd!
|
|
||||||
autocmd User Flags call Hoist('buffer', function('FugitiveStatusline'))
|
|
||||||
augroup END
|
|
||||||
|
|
||||||
" Section: Folding
|
" Section: Folding
|
||||||
|
|
||||||
function! fugitive#Foldtext() abort
|
function! fugitive#Foldtext() abort
|
||||||
@@ -3220,11 +3222,3 @@ endfunction
|
|||||||
function! fugitive#foldtext() abort
|
function! fugitive#foldtext() abort
|
||||||
return fugitive#Foldtext()
|
return fugitive#Foldtext()
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
augroup fugitive_foldtext
|
|
||||||
autocmd!
|
|
||||||
autocmd User Fugitive
|
|
||||||
\ if &filetype =~# '^git\%(commit\)\=$' && &foldtext ==# 'foldtext()' |
|
|
||||||
\ set foldtext=fugitive#Foldtext() |
|
|
||||||
\ endif
|
|
||||||
augroup END
|
|
||||||
|
|||||||
Reference in New Issue
Block a user