mirror of
https://github.com/tpope/vim-fugitive.git
synced 2025-11-12 05:13:53 -05:00
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:
@@ -4553,17 +4553,6 @@ function! s:Keywordprg() abort
|
|||||||
endif
|
endif
|
||||||
endfunction
|
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
|
function! s:linechars(pattern) abort
|
||||||
let chars = strlen(s:gsub(matchstr(getline('.'), a:pattern), '.', '.'))
|
let chars = strlen(s:gsub(matchstr(getline('.'), a:pattern), '.', '.'))
|
||||||
if exists('*synconcealed') && &conceallevel > 1
|
if exists('*synconcealed') && &conceallevel > 1
|
||||||
@@ -4745,27 +4734,10 @@ function! s:BlameCommand(line1, line2, range, count, bang, mods, reg, arg, args)
|
|||||||
setlocal cursorbind
|
setlocal cursorbind
|
||||||
endif
|
endif
|
||||||
setlocal nonumber scrollbind nowrap foldcolumn=0 nofoldenable winfixwidth
|
setlocal nonumber scrollbind nowrap foldcolumn=0 nofoldenable winfixwidth
|
||||||
if exists('+concealcursor')
|
|
||||||
setlocal concealcursor=nc conceallevel=2
|
|
||||||
endif
|
|
||||||
if exists('+relativenumber')
|
if exists('+relativenumber')
|
||||||
setlocal norelativenumber
|
setlocal norelativenumber
|
||||||
endif
|
endif
|
||||||
execute "vertical resize ".(s:linechars('.\{-\}\ze\s\+\d\+)')+1)
|
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> 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> 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>
|
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
|
endif
|
||||||
exe 'syn match FugitiveblameHash'.hash.' "\%(^\^\=\)\@<='.hash.'\x\{1,34\}\>" nextgroup=FugitiveblameAnnotation,FugitiveblameOriginalLineNumber,fugitiveblameOriginalFile skipwhite'
|
exe 'syn match FugitiveblameHash'.hash.' "\%(^\^\=\)\@<='.hash.'\x\{1,34\}\>" nextgroup=FugitiveblameAnnotation,FugitiveblameOriginalLineNumber,fugitiveblameOriginalFile skipwhite'
|
||||||
endfor
|
endfor
|
||||||
call s:RehighlightBlame()
|
call s:BlameRehighlight()
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:RehighlightBlame() abort
|
function! s:BlameRehighlight() abort
|
||||||
for [hash, cterm] in items(s:hash_colors)
|
for [hash, cterm] in items(s:hash_colors)
|
||||||
if !empty(cterm) || has('gui_running') || has('termguicolors') && &termguicolors
|
if !empty(cterm) || has('gui_running') || has('termguicolors') && &termguicolors
|
||||||
exe 'hi FugitiveblameHash'.hash.' guifg=#'.hash.get(s:hash_colors, hash, '')
|
exe 'hi FugitiveblameHash'.hash.' guifg=#'.hash.get(s:hash_colors, hash, '')
|
||||||
@@ -4929,6 +4901,47 @@ function! s:RehighlightBlame() abort
|
|||||||
endfor
|
endfor
|
||||||
endfunction
|
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
|
" Section: :Gbrowse
|
||||||
|
|
||||||
call s:command("-bar -bang -range=-1 -nargs=* -complete=customlist,fugitive#CompleteObject Gbrowse", "Browse")
|
call s:command("-bar -bang -range=-1 -nargs=* -complete=customlist,fugitive#CompleteObject Gbrowse", "Browse")
|
||||||
|
|||||||
Reference in New Issue
Block a user