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:
Tim Pope
2023-02-05 18:40:33 -05:00
parent 2febbe1f00
commit 2019e0e413
2 changed files with 5 additions and 2 deletions

View File

@@ -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"')