mirror of
https://github.com/tpope/vim-fugitive.git
synced 2025-11-08 11:33:47 -05:00
Support folding sections
Resolves: https://github.com/tpope/vim-fugitive/issues/2111 References: https://github.com/tpope/vim-fugitive/issues/1317
This commit is contained in:
@@ -8124,6 +8124,9 @@ function! fugitive#Foldtext() abort
|
||||
endif
|
||||
elseif line_foldstart =~# '^@@\+ .* @@'
|
||||
return '+-' . v:folddashes . ' ' . line_foldstart
|
||||
elseif &filetype ==# 'fugitive' && line_foldstart =~# '^[A-Z][a-z].* (\d\+)$'
|
||||
let c = +matchstr(line_foldstart, '(\zs\d\+\ze)$')
|
||||
return '+-' . v:folddashes . printf('%3d item', c) . (c == 1 ? ': ' : 's: ') . matchstr(line_foldstart, '.*\ze (\d\+)$')
|
||||
elseif &filetype ==# 'gitcommit' && line_foldstart =~# '^# .*:$'
|
||||
let lines = getline(v:foldstart, v:foldend)
|
||||
call filter(lines, 'v:val =~# "^#\t"')
|
||||
|
||||
@@ -13,7 +13,7 @@ syn match fugitiveHeader /^Pull:\|^Rebase:\|^Merge:\|^Push:/ nextgroup=fugitiveS
|
||||
syn match fugitiveHelpHeader /^Help:/ nextgroup=fugitiveHelpTag skipwhite
|
||||
syn match fugitiveHelpTag /\S\+/ contained
|
||||
|
||||
syn region fugitiveSection start=/^\%(.*(\d\++\=)$\)\@=/ contains=fugitiveHeading end=/^$/
|
||||
syn region fugitiveSection start=/^\%(.*(\d\++\=)$\)\@=/ contains=fugitiveHeading end=/^$/ fold
|
||||
syn cluster fugitiveSection contains=fugitiveSection
|
||||
syn match fugitiveHeading /^[A-Z][a-z][^:]*\ze (\d\++\=)$/ contains=fugitivePreposition contained nextgroup=fugitiveCount skipwhite
|
||||
syn match fugitiveCount /(\d\++\=)/hs=s+1,he=e-1 contained
|
||||
@@ -30,7 +30,7 @@ syn match fugitiveHash /\S\@<!\x\{4,\}\S\@!/ contained
|
||||
syn region fugitiveHunk start=/^\%(@@\+ -\)\@=/ end=/^\%([A-Za-z?@]\|$\)\@=/ contains=diffLine,diffRemoved,diffAdded,diffNoEOL containedin=@fugitiveSection fold
|
||||
|
||||
for s:section in ['Untracked', 'Unstaged', 'Staged']
|
||||
exe 'syn region fugitive' . s:section . 'Section start=/^\%(' . s:section . ' .*(\d\++\=)$\)\@=/ contains=fugitive' . s:section . 'Heading end=/^$/'
|
||||
exe 'syn region fugitive' . s:section . 'Section start=/^\%(' . s:section . ' .*(\d\++\=)$\)\@=/ contains=fugitive' . s:section . 'Heading end=/^$/ fold'
|
||||
exe 'syn match fugitive' . s:section . 'Modifier /^[MADRCU?] / contained containedin=fugitive' . s:section . 'Section'
|
||||
exe 'syn cluster fugitiveSection add=fugitive' . s:section . 'Section'
|
||||
exe 'syn match fugitive' . s:section . 'Heading /^[A-Z][a-z][^:]*\ze (\d\++\=)$/ contains=fugitivePreposition contained nextgroup=fugitiveCount skipwhite'
|
||||
|
||||
Reference in New Issue
Block a user