Conceal file names and line numbers in :Gblame
This commit is contained in:
parent
daccfb508f
commit
f43393dd9a
@ -1554,7 +1554,13 @@ augroup fugitive_blame
|
||||
augroup END
|
||||
|
||||
function! s:linechars(pattern)
|
||||
return strlen(s:gsub(matchstr(getline('.'), a:pattern), '.', '.'))
|
||||
let chars = strlen(s:gsub(matchstr(getline('.'), a:pattern), '.', '.'))
|
||||
if exists('*synconcealed') && &conceallevel > 1
|
||||
for col in range(1, chars)
|
||||
let chars -= synconcealed(line('.'), col)[0]
|
||||
endfor
|
||||
endif
|
||||
return chars
|
||||
endfunction
|
||||
|
||||
function! s:Blame(bang,line1,line2,count,args) abort
|
||||
@ -1621,11 +1627,14 @@ function! s:Blame(bang,line1,line2,count,args) abort
|
||||
execute top
|
||||
normal! zt
|
||||
execute current
|
||||
execute "vertical resize ".(s:linechars('.\{-\}\ze\s\+\d\+)')+1)
|
||||
setlocal nomodified nomodifiable nonumber scrollbind nowrap foldcolumn=0 nofoldenable filetype=fugitiveblame
|
||||
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> q :exe substitute(bufwinnr(b:fugitive_blamed_bufnr).' wincmd w<Bar>'.bufnr('').'bdelete','^-1','','')<CR>
|
||||
nnoremap <buffer> <silent> gq :exe substitute(bufwinnr(b:fugitive_blamed_bufnr).' wincmd w<Bar>'.bufnr('').'bdelete<Bar>if expand("%:p") =~# "^fugitive:[\\/][\\/]"<Bar>Gedit<Bar>endif','^-1','','')<CR>
|
||||
nnoremap <buffer> <silent> <CR> :<C-U>exe <SID>BlameJump('')<CR>
|
||||
@ -1729,17 +1738,19 @@ endfunction
|
||||
|
||||
function! s:BlameSyntax() abort
|
||||
let b:current_syntax = 'fugitiveblame'
|
||||
let conceal = has('conceal') ? ' conceal' : ''
|
||||
let arg = exists('b:fugitive_blame_arguments') ? b:fugitive_blame_arguments : ''
|
||||
syn match FugitiveblameBoundary "^\^"
|
||||
syn match FugitiveblameBlank "^\s\+\s\@=" nextgroup=FugitiveblameAnnotation,fugitiveblameOriginalFile,FugitiveblameOriginalLineNumber skipwhite
|
||||
syn match FugitiveblameHash "\%(^\^\=\)\@<=\x\{7,40\}\>" nextgroup=FugitiveblameAnnotation,FugitiveblameOriginalLineNumber,fugitiveblameOriginalFile skipwhite
|
||||
syn match FugitiveblameUncommitted "\%(^\^\=\)\@<=0\{7,40\}\>" nextgroup=FugitiveblameAnnotation,FugitiveblameOriginalLineNumber,fugitiveblameOriginalFile skipwhite
|
||||
syn region FugitiveblameAnnotation matchgroup=FugitiveblameDelimiter start="(" end="\%( \d\+\)\@<=)" contained keepend oneline
|
||||
syn match FugitiveblameTime "[0-9:/+-][0-9:/+ -]*[0-9:/+-]\%( \+\d\+)\)\@=" contained containedin=FugitiveblameAnnotation
|
||||
syn match FugitiveblameLineNumber " \@<=\d\+)\@=" contained containedin=FugitiveblameAnnotation
|
||||
syn match FugitiveblameOriginalFile " \%(\f\+\D\@<=\|\D\@=\f\+\)\%(\%(\s\+\d\+\)\=\s\%((\|\s*\d\+)\)\)\@=" contained nextgroup=FugitiveblameOriginalLineNumber,FugitiveblameAnnotation skipwhite
|
||||
syn match FugitiveblameOriginalLineNumber " \@<=\d\+\%(\s(\)\@=" contained nextgroup=FugitiveblameAnnotation skipwhite
|
||||
syn match FugitiveblameOriginalLineNumber " \@<=\d\+\%(\s\+\d\+)\)\@=" contained nextgroup=FugitiveblameShort skipwhite
|
||||
syn match FugitiveblameShort "\d\+)" contained contains=FugitiveblameLineNumber
|
||||
exec 'syn match FugitiveblameLineNumber " *\d\+)\@=" contained containedin=FugitiveblameAnnotation'.conceal
|
||||
exec 'syn match FugitiveblameOriginalFile " \%(\f\+\D\@<=\|\D\@=\f\+\)\%(\%(\s\+\d\+\)\=\s\%((\|\s*\d\+)\)\)\@=" contained nextgroup=FugitiveblameOriginalLineNumber,FugitiveblameAnnotation skipwhite'.(arg =~# 'f' ? '' : conceal)
|
||||
exec 'syn match FugitiveblameOriginalLineNumber " *\d\+\%(\s(\)\@=" contained nextgroup=FugitiveblameAnnotation skipwhite'.(arg =~# 'n' ? '' : conceal)
|
||||
exec 'syn match FugitiveblameOriginalLineNumber " *\d\+\%(\s\+\d\+)\)\@=" contained nextgroup=FugitiveblameShort skipwhite'.(arg =~# 'n' ? '' : conceal)
|
||||
syn match FugitiveblameShort " \d\+)" contained contains=FugitiveblameLineNumber
|
||||
syn match FugitiveblameNotCommittedYet "(\@<=Not Committed Yet\>" contained containedin=FugitiveblameAnnotation
|
||||
hi def link FugitiveblameBoundary Keyword
|
||||
hi def link FugitiveblameHash Identifier
|
||||
|
Loading…
Reference in New Issue
Block a user