mirror of
https://github.com/tpope/vim-fugitive.git
synced 2025-11-10 04:23:46 -05:00
Adjust User events for fugitive:// buffers
This commit is contained in:
@@ -186,13 +186,13 @@ function! s:TempScript(...) abort
|
|||||||
return FugitiveGitPath(temp)
|
return FugitiveGitPath(temp)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:DoAutocmd(cmd) abort
|
function! s:DoAutocmd(...) abort
|
||||||
if v:version >= 704 || (v:version == 703 && has('patch442'))
|
if v:version >= 704 || (v:version == 703 && has('patch442'))
|
||||||
return 'doautocmd <nomodeline>' . a:cmd
|
return join(map(copy(a:000), "'doautocmd <nomodeline>' . v:val"), '|')
|
||||||
elseif &modelines > 0
|
elseif &modelines > 0
|
||||||
return 'try|set modelines=0|doautocmd ' . a:cmd . '|finally|set modelines=' . &modelines . '|endtry'
|
return 'try|set modelines=0|' . join(map(copy(a:000), "'doautocmd ' . v:val"), '|') . '|finally|set modelines=' . &modelines . '|endtry'
|
||||||
else
|
else
|
||||||
return 'doautocmd ' . a:cmd
|
return join(map(copy(a:000), "'doautocmd ' . v:val"), '|')
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
@@ -2270,6 +2270,11 @@ endfunction
|
|||||||
|
|
||||||
" Section: Buffer auto-commands
|
" Section: Buffer auto-commands
|
||||||
|
|
||||||
|
augroup fugitive_dummy_events
|
||||||
|
autocmd!
|
||||||
|
autocmd User Fugitive* "
|
||||||
|
augroup END
|
||||||
|
|
||||||
function! s:ReplaceCmd(cmd) abort
|
function! s:ReplaceCmd(cmd) abort
|
||||||
let temp = tempname()
|
let temp = tempname()
|
||||||
let [err, exec_error] = s:StdoutToFile(temp, a:cmd)
|
let [err, exec_error] = s:StdoutToFile(temp, a:cmd)
|
||||||
@@ -2672,7 +2677,7 @@ function! fugitive#BufReadStatus() abort
|
|||||||
endfor
|
endfor
|
||||||
|
|
||||||
let b:fugitive_reltime = reltime()
|
let b:fugitive_reltime = reltime()
|
||||||
return 'silent ' . s:DoAutocmd('User FugitiveIndex')
|
return s:DoAutocmd('User FugitiveIndex')
|
||||||
catch /^fugitive:/
|
catch /^fugitive:/
|
||||||
return 'echoerr ' . string(v:exception)
|
return 'echoerr ' . string(v:exception)
|
||||||
endtry
|
endtry
|
||||||
@@ -2784,6 +2789,8 @@ function! fugitive#BufReadCmd(...) abort
|
|||||||
silent keepjumps %delete_
|
silent keepjumps %delete_
|
||||||
setlocal endofline
|
setlocal endofline
|
||||||
|
|
||||||
|
let events = ['User FugitiveObject', 'User Fugitive' . substitute(b:fugitive_type, '^\l', '\u&', '')]
|
||||||
|
|
||||||
try
|
try
|
||||||
if b:fugitive_type !=# 'blob'
|
if b:fugitive_type !=# 'blob'
|
||||||
setlocal foldmarker=<<<<<<<<,>>>>>>>>
|
setlocal foldmarker=<<<<<<<<,>>>>>>>>
|
||||||
@@ -2835,6 +2842,9 @@ function! fugitive#BufReadCmd(...) abort
|
|||||||
keepjumps call setpos('.',pos)
|
keepjumps call setpos('.',pos)
|
||||||
setlocal nomodified noswapfile
|
setlocal nomodified noswapfile
|
||||||
let modifiable = rev =~# '^:.:' && b:fugitive_type !=# 'tree'
|
let modifiable = rev =~# '^:.:' && b:fugitive_type !=# 'tree'
|
||||||
|
if modifiable
|
||||||
|
let events = ['User FugitiveStageBlob']
|
||||||
|
endif
|
||||||
let &l:readonly = !modifiable || !filewritable(fugitive#Find('.git/index', dir))
|
let &l:readonly = !modifiable || !filewritable(fugitive#Find('.git/index', dir))
|
||||||
if empty(&bufhidden)
|
if empty(&bufhidden)
|
||||||
setlocal bufhidden=delete
|
setlocal bufhidden=delete
|
||||||
@@ -2851,8 +2861,8 @@ function! fugitive#BufReadCmd(...) abort
|
|||||||
setlocal modifiable
|
setlocal modifiable
|
||||||
|
|
||||||
return 'silent ' . s:DoAutocmd('BufReadPost') .
|
return 'silent ' . s:DoAutocmd('BufReadPost') .
|
||||||
\ (modifiable ? '' : '|setl nomodifiable') . '|silent ' .
|
\ (modifiable ? '' : '|setl nomodifiable') . '|' .
|
||||||
\ s:DoAutocmd('User Fugitive' . substitute(b:fugitive_type, '^\l', '\u&', ''))
|
\ call('s:DoAutocmd', events)
|
||||||
catch /^fugitive:/
|
catch /^fugitive:/
|
||||||
return 'echoerr ' . string(v:exception)
|
return 'echoerr ' . string(v:exception)
|
||||||
endtry
|
endtry
|
||||||
|
|||||||
@@ -620,11 +620,8 @@ AUTOCOMMANDS *fugitive-autocommands*
|
|||||||
A handful of |User| |autocommands| are provided to allow extending and
|
A handful of |User| |autocommands| are provided to allow extending and
|
||||||
overriding Fugitive behaviors. Example usage:
|
overriding Fugitive behaviors. Example usage:
|
||||||
>
|
>
|
||||||
autocmd User FugitiveBlob call s:BlobOverrides()
|
autocmd User FugitiveBlob,FugitiveStageBlob call s:BlobOverrides()
|
||||||
<
|
<
|
||||||
*User_FugitiveIndex*
|
|
||||||
FugitiveIndex After loading the |fugitive-summary| buffer.
|
|
||||||
|
|
||||||
*User_FugitiveTag*
|
*User_FugitiveTag*
|
||||||
FugitiveTag After loading a tag object.
|
FugitiveTag After loading a tag object.
|
||||||
|
|
||||||
@@ -635,10 +632,18 @@ FugitiveCommit After loading a commit object.
|
|||||||
FugitiveTree After loading a tree (directory) object.
|
FugitiveTree After loading a tree (directory) object.
|
||||||
|
|
||||||
*User_FugitiveBlob*
|
*User_FugitiveBlob*
|
||||||
FugitiveBlob After loading a blob (file) object. This includes
|
FugitiveBlob After loading a committed blob (file) object.
|
||||||
both committed blobs which are read only, and staged
|
|
||||||
blobs which can be edited and written. Check
|
*User_FugitiveObject*
|
||||||
&modifiable to distinguish between the two.
|
FugitiveObject After loading any of the 4 above buffer types.
|
||||||
|
|
||||||
|
*User_FugitiveStageBlob*
|
||||||
|
FugitiveStageBlob After loading a staged blob (file) object. These
|
||||||
|
buffers are 'modifiable' and oftentimes don't want the
|
||||||
|
same behavior as the other buffer types.
|
||||||
|
|
||||||
|
*User_FugitiveIndex*
|
||||||
|
FugitiveIndex After loading the |fugitive-summary| buffer.
|
||||||
|
|
||||||
*User_FugitiveChanged*
|
*User_FugitiveChanged*
|
||||||
FugitiveChanged After any event which can potentially change the
|
FugitiveChanged After any event which can potentially change the
|
||||||
|
|||||||
Reference in New Issue
Block a user