Move blame buffer settings to FileType event
The goal here is to extract just the settings that would work outside of a vertical split with 'scrollbind' in effect, so we can one day add a second mode.
This commit is contained in:
parent
4daa0c558c
commit
d417fd3199
@ -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(<line1>,<line2>,+'<range>',<count>,<bang>0,'<mods>',<q-reg>,<q-args>,[<f-args>])" |
|
||||
\ endif
|
||||
autocmd ColorScheme,GUIEnter * call s:RehighlightBlame()
|
||||
autocmd BufWinLeave * execute getwinvar(+bufwinnr(+expand('<abuf>')), '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 <buffer> <silent> <F1> :help fugitive-:Gblame<CR>
|
||||
nnoremap <buffer> <silent> g? :help fugitive-:Gblame<CR>
|
||||
if mapcheck('q', 'n') =~# '^$\|bdelete'
|
||||
nnoremap <buffer> <silent> q :exe <SID>BlameQuit()<Bar>echohl WarningMsg<Bar>echo ":Gblame q is deprecated in favor of gq"<Bar>echohl NONE<CR>
|
||||
endif
|
||||
exe 'nnoremap <buffer> <silent>' s:nowait "gq :exe <SID>BlameQuit()<CR>"
|
||||
nnoremap <buffer> <silent> <CR> :<C-U>exe <SID>BlameCommit("exe <SID>BlameLeave()<Bar>edit")<CR>
|
||||
nnoremap <buffer> <silent> - :<C-U>exe <SID>BlameJump('')<CR>
|
||||
nnoremap <buffer> <silent> P :<C-U>exe <SID>BlameJump('^'.v:count1)<CR>
|
||||
nnoremap <buffer> <silent> ~ :<C-U>exe <SID>BlameJump('~'.v:count1)<CR>
|
||||
nnoremap <buffer> <silent> i :<C-U>exe <SID>BlameCommit("exe <SID>BlameLeave()<Bar>edit")<CR>
|
||||
nnoremap <buffer> <silent> o :<C-U>exe <SID>BlameCommit("split")<CR>
|
||||
nnoremap <buffer> <silent> O :<C-U>exe <SID>BlameCommit("tabedit")<CR>
|
||||
nnoremap <buffer> <silent> p :<C-U>exe <SID>BlameCommit("pedit")<CR>
|
||||
nnoremap <buffer> <silent> A :<C-u>exe "vertical resize ".(<SID>linechars('.\{-\}\ze [0-9:/+-][0-9:/+ -]* \d\+)')+1+v:count)<CR>
|
||||
nnoremap <buffer> <silent> C :<C-u>exe "vertical resize ".(<SID>linechars('^\S\+')+1+v:count)<CR>
|
||||
nnoremap <buffer> <silent> D :<C-u>exe "vertical resize ".(<SID>linechars('.\{-\}\ze\d\ze\s\+\d\+)')+1-v:count)<CR>
|
||||
@ -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 <buffer> <silent> <F1> :help fugitive-:Gblame<CR>
|
||||
nnoremap <buffer> <silent> g? :help fugitive-:Gblame<CR>
|
||||
if mapcheck('q', 'n') =~# '^$\|bdelete'
|
||||
nnoremap <buffer> <silent> q :exe <SID>BlameQuit()<Bar>echohl WarningMsg<Bar>echo ":Gblame q is deprecated in favor of gq"<Bar>echohl NONE<CR>
|
||||
endif
|
||||
exe 'nnoremap <buffer> <silent>' s:nowait "gq :exe <SID>BlameQuit()<CR>"
|
||||
nnoremap <buffer> <silent> <CR> :<C-U>exe <SID>BlameCommit("exe <SID>BlameLeave()<Bar>edit")<CR>
|
||||
nnoremap <buffer> <silent> - :<C-U>exe <SID>BlameJump('')<CR>
|
||||
nnoremap <buffer> <silent> P :<C-U>exe <SID>BlameJump('^'.v:count1)<CR>
|
||||
nnoremap <buffer> <silent> ~ :<C-U>exe <SID>BlameJump('~'.v:count1)<CR>
|
||||
nnoremap <buffer> <silent> i :<C-U>exe <SID>BlameCommit("exe <SID>BlameLeave()<Bar>edit")<CR>
|
||||
nnoremap <buffer> <silent> o :<C-U>exe <SID>BlameCommit("split")<CR>
|
||||
nnoremap <buffer> <silent> O :<C-U>exe <SID>BlameCommit("tabedit")<CR>
|
||||
nnoremap <buffer> <silent> p :<C-U>exe <SID>BlameCommit("pedit")<CR>
|
||||
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(<line1>,<line2>,+'<range>',<count>,<bang>0,'<mods>',<q-reg>,<q-args>,[<f-args>])" |
|
||||
\ endif
|
||||
autocmd ColorScheme,GUIEnter * call s:BlameRehighlight()
|
||||
autocmd BufWinLeave * execute getwinvar(+bufwinnr(+expand('<abuf>')), 'fugitive_leave')
|
||||
augroup END
|
||||
|
||||
" Section: :Gbrowse
|
||||
|
||||
call s:command("-bar -bang -range=-1 -nargs=* -complete=customlist,fugitive#CompleteObject Gbrowse", "Browse")
|
||||
|
Loading…
Reference in New Issue
Block a user