X-Git-Url: https://git.rmz.io/dotfiles.git/blobdiff_plain/ec103556f2e0a25af006b0e3096cf00f10d24793..fdd63454b51a35418ec23d3489cf20ae66a2299d:/vim/ftplugin/cpp.vim diff --git a/vim/ftplugin/cpp.vim b/vim/ftplugin/cpp.vim index ea6837f..19850a7 100644 --- a/vim/ftplugin/cpp.vim +++ b/vim/ftplugin/cpp.vim @@ -88,3 +88,18 @@ function! InitialFoldLevel() endif endf call InitialFoldLevel() + +function! MyCppFoldText() + let l:line = getline(v:foldstart) + " expand tabs in line, foldtext does not do it on its own + let l:line = substitute(l:line, "\t", repeat(" ", shiftwidth()), "g") + let l:width = min([&textwidth, winwidth(0)]) + let l:lineinfo = printf("%d", v:foldend - v:foldstart) + let l:ellipsis = "…" + return printf("%.*s%s%*d", + \ l:width - strdisplaywidth(l:ellipsis..l:lineinfo), l:line, + \ l:ellipsis, + \ l:width - strdisplaywidth(l:line..l:ellipsis), l:lineinfo) +endfunction +setlocal foldtext=MyCppFoldText() +setlocal fillchars+=fold:\