From 2019e0e4139390f485a024d7a2411218b004a5b3 Mon Sep 17 00:00:00 2001 From: Tim Pope Date: Sun, 5 Feb 2023 18:40:33 -0500 Subject: [PATCH] Support folding sections Resolves: https://github.com/tpope/vim-fugitive/issues/2111 References: https://github.com/tpope/vim-fugitive/issues/1317 --- autoload/fugitive.vim | 3 +++ syntax/fugitive.vim | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim index ce16048..ea9820b 100644 --- a/autoload/fugitive.vim +++ b/autoload/fugitive.vim @@ -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"') diff --git a/syntax/fugitive.vim b/syntax/fugitive.vim index e61b34f..c7fe201 100644 --- a/syntax/fugitive.vim +++ b/syntax/fugitive.vim @@ -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\@