diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim index d81bb58..0dd6d0c 100644 --- a/autoload/fugitive.vim +++ b/autoload/fugitive.vim @@ -4553,17 +4553,6 @@ function! s:Keywordprg() abort endif endfunction -augroup fugitive_blame - autocmd! - autocmd FileType fugitiveblame setlocal nomodeline | if len(s:Dir()) | let &l:keywordprg = s:Keywordprg() | endif - autocmd User Fugitive - \ if get(b:, 'fugitive_type') =~# '^\%(file\|blob\)$' || s:BlameBufnr() > 0 || filereadable(@%) | - \ exe "command! -buffer -bar -bang -range=-1 -nargs=* -complete=customlist,s:BlameComplete Gblame :execute s:BlameCommand(,,+'',,0,'',,,[])" | - \ endif - autocmd ColorScheme,GUIEnter * call s:RehighlightBlame() - autocmd BufWinLeave * execute getwinvar(+bufwinnr(+expand('')), 'fugitive_leave') -augroup END - function! s:linechars(pattern) abort let chars = strlen(s:gsub(matchstr(getline('.'), a:pattern), '.', '.')) if exists('*synconcealed') && &conceallevel > 1 @@ -4745,27 +4734,10 @@ function! s:BlameCommand(line1, line2, range, count, bang, mods, reg, arg, args) setlocal cursorbind endif setlocal nonumber scrollbind nowrap foldcolumn=0 nofoldenable winfixwidth - if exists('+concealcursor') - setlocal concealcursor=nc conceallevel=2 - endif if exists('+relativenumber') setlocal norelativenumber endif execute "vertical resize ".(s:linechars('.\{-\}\ze\s\+\d\+)')+1) - nnoremap :help fugitive-:Gblame - nnoremap g? :help fugitive-:Gblame - if mapcheck('q', 'n') =~# '^$\|bdelete' - nnoremap q :exe BlameQuit()echohl WarningMsgecho ":Gblame q is deprecated in favor of gq"echohl NONE - endif - exe 'nnoremap ' s:nowait "gq :exe BlameQuit()" - nnoremap :exe BlameCommit("exe BlameLeave()edit") - nnoremap - :exe BlameJump('') - nnoremap P :exe BlameJump('^'.v:count1) - nnoremap ~ :exe BlameJump('~'.v:count1) - nnoremap i :exe BlameCommit("exe BlameLeave()edit") - nnoremap o :exe BlameCommit("split") - nnoremap O :exe BlameCommit("tabedit") - nnoremap p :exe BlameCommit("pedit") nnoremap A :exe "vertical resize ".(linechars('.\{-\}\ze [0-9:/+-][0-9:/+ -]* \d\+)')+1+v:count) nnoremap C :exe "vertical resize ".(linechars('^\S\+')+1+v:count) nnoremap D :exe "vertical resize ".(linechars('.\{-\}\ze\d\ze\s\+\d\+)')+1-v:count) @@ -4916,10 +4888,10 @@ function! fugitive#BlameSyntax() abort endif exe 'syn match FugitiveblameHash'.hash.' "\%(^\^\=\)\@<='.hash.'\x\{1,34\}\>" nextgroup=FugitiveblameAnnotation,FugitiveblameOriginalLineNumber,fugitiveblameOriginalFile skipwhite' endfor - call s:RehighlightBlame() + call s:BlameRehighlight() endfunction -function! s:RehighlightBlame() abort +function! s:BlameRehighlight() abort for [hash, cterm] in items(s:hash_colors) if !empty(cterm) || has('gui_running') || has('termguicolors') && &termguicolors exe 'hi FugitiveblameHash'.hash.' guifg=#'.hash.get(s:hash_colors, hash, '') @@ -4929,6 +4901,47 @@ function! s:RehighlightBlame() abort endfor endfunction +function! s:BlameFileType() abort + setlocal nomodeline + setlocal foldmethod=manual + if len(s:Dir()) + let &l:keywordprg = s:Keywordprg() + endif + let b:undo_ftplugin = 'setl keywordprg= foldmethod<' + if exists('+concealcursor') + setlocal concealcursor=nc conceallevel=2 + let b:undo_ftplugin .= ' concealcursor< conceallevel<' + endif + if &modifiable + return '' + endif + nnoremap :help fugitive-:Gblame + nnoremap g? :help fugitive-:Gblame + if mapcheck('q', 'n') =~# '^$\|bdelete' + nnoremap q :exe BlameQuit()echohl WarningMsgecho ":Gblame q is deprecated in favor of gq"echohl NONE + endif + exe 'nnoremap ' s:nowait "gq :exe BlameQuit()" + nnoremap :exe BlameCommit("exe BlameLeave()edit") + nnoremap - :exe BlameJump('') + nnoremap P :exe BlameJump('^'.v:count1) + nnoremap ~ :exe BlameJump('~'.v:count1) + nnoremap i :exe BlameCommit("exe BlameLeave()edit") + nnoremap o :exe BlameCommit("split") + nnoremap O :exe BlameCommit("tabedit") + nnoremap p :exe BlameCommit("pedit") +endfunction + +augroup fugitive_blame + autocmd! + autocmd FileType fugitiveblame call s:BlameFileType() + autocmd User Fugitive + \ if get(b:, 'fugitive_type') =~# '^\%(file\|blob\)$' || s:BlameBufnr() > 0 || filereadable(@%) | + \ exe "command! -buffer -bar -bang -range=-1 -nargs=* -complete=customlist,s:BlameComplete Gblame :execute s:BlameCommand(,,+'',,0,'',,,[])" | + \ endif + autocmd ColorScheme,GUIEnter * call s:BlameRehighlight() + autocmd BufWinLeave * execute getwinvar(+bufwinnr(+expand('')), 'fugitive_leave') +augroup END + " Section: :Gbrowse call s:command("-bar -bang -range=-1 -nargs=* -complete=customlist,fugitive#CompleteObject Gbrowse", "Browse")